[python-win32] opening files with names in non-english characters.

Vernon Cole vernondcole at gmail.com
Tue Feb 24 22:30:34 CET 2009


1) Comparing the time it would take to walk a directory tree thousands
of times, with the storage it would take to store thousands of file
names, I think you would be much better of to store the list.  Buy
another memory chip if needed.

2) I suspect that Python is NOT returning question mark characters.
Windows (or KIMODO) is probably failing to display some characters
that Python is returning.  Try using
>>> print repr(yourFileNameObjectHere)
to see what is really in that object. You cannot expect your display
to have the glyph for every arbitrary unicode code point, so repr()
will display it with backslash escapes so that you can tell what is
there.

3) The documentation for "os.listdir(path)" says: "Changed in version
2.3: On Windows NT/2k/XP and Unix, if path is a Unicode object, the
result will be a list of Unicode objects."  Make sure that your path
argument is a unicode object.
myPath = unicode(someStringObject)
or
myPath = u'somePath'
--
Vernon Cole


More information about the python-win32 mailing list