import string


def slug(strng):
    """Converts a string to one that is appropriate for a filename.

    :param strng: The input string.
    :type strng: str
    :return: The filename appropriate string.
    :rtype: str
    """

    # See
    # https://stackoverflow.com/questions/295135/turn-a-string-into-a-valid-filename
    valid_chars = "-_.%s%s" % (string.ascii_letters, string.digits)
    if strng == "":
        return "untitled"
    else:
        return "".join([c if c in valid_chars else "_" for c in strng])