making a valid file name...
bjobrien62 at gmail.com
Tue Oct 17 18:22:45 CEST 2006
Hi I'm writing a python script that creates directories from user
Sometimes the user inputs characters that aren't valid characters for a
file or directory name.
Here are the characters that I consider to be valid characters...
if I have a string called fname I want to go through each character in
the filename and if it is not a valid character, then I want to replace
it with a space.
This is what I have:
for i in range(len(fname)):
if valid.find(fname[i]) < 0:
fname[i] = ' '
Anyone think of a simpler solution?
More information about the Python-list