os.lisdir, gets unicode, returns unicode... USUALLY?!?!?

Laurent Pointal laurent.pointal at limsi.fr
Fri Nov 17 03:52:35 EST 2006


gabor a écrit :
> hi,
> 
> from the documentation (http://docs.python.org/lib/os-file-dir.html) for
> os.listdir:
> 
> "On Windows NT/2k/XP and Unix, if path is a Unicode object, the result
> will be a list of Unicode objects."

Maybe, for each filename, you can test if it is an unicode string, and
if not, convert it to unicode using the encoding indicated by
sys.getfilesystemencoding().

Have a try.

A+

Laurent.



More information about the Python-list mailing list