def to_valid_filename(s):
 valid_chars = ('-_.() %s%s' % (string.ascii_letters, string.digits))
 return ''.join((c for c in s if (c in valid_chars)))

def to_valid_filename ( s ) : valid_chars = ( '-_.() %s%s' % ( string . ascii_letters , string . digits ) ) return '' . join ( ( c for c in s if ( c in valid_chars ) ) )
converts arbitrary string into a valid file name for caching .