[Pythonmac-SIG] Problems with file names

Bob Ippolito bob at redivi.com
Sun Nov 7 02:20:14 CET 2004


On Nov 6, 2004, at 17:05, Pierre Thibault wrote:

> I have a little problem with the Python script I wrote. I am unable to 
> treat some file names containing accentued characters or special 
> characters like '. I use the os.walk() generator to traverse my 
> hierarchy of files. I then use commands.getstatusoutput('md5 ' + "'" + 
> fileName + "'") to execute the md5 command on the files I want.
>
> This is working well for most of my files but not for file names 
> containing accentued characters or special characters like ' as I said 
> before. Is there a way to reformat fineName to avoid these errors? Is 
> there a special Unix command that I don't know to do that?
>
> Any help or idea on how to solve this problem would be appreciated.

Don't use the commands module, os.system, os.popen, etc.  EVER.  They 
all suck.  Use the subprocess module from Python 2.4.

Everything you need to know is in PEP 0324: 
http://www.python.org/peps/pep-0324.html

-bob



More information about the Pythonmac-SIG mailing list