I would suggest something like string.maketrans http://docs.python.org/lib/node41.html. I don't remember exactly how it works, but I think it's something like
>>> invalid_chars = "abc" >>> replace_chars = "123" >>> char_map = string.maketrans(invalid_chars, replace_chars) >>> filename = "abc123.txt" >>> filename.translate(charmap) '123123.txt' -- Jerry -- http://mail.python.org/mailman/listinfo/python-list