os.lisdir, gets unicode, returns unicode... USUALLY?!?!?  gabor
gabor at nekomancer.net Thu Nov 16 22:05:19 CET 2006   from the
documentation (http://docs.python.org/lib/os-file-dir.html) for
"On Windows NT/2k/XP and Unix, if path is a Unicode object, the
result  will be a list of Unicode objects."  i'm on Unix.
(linux, ubuntu edgy)  so it seems that it does not always return
unicode filenames.  it seems that it tries to interpret the
filenames using the filesystem's  encoding, and if that fails,
it simply returns the filename as byte-string.  so you get back
let's say an array of 21 filenames, from which 3 are  byte-
strings, and the rest unicode strings.  after digging around, i
found this in the source code:  >                 if
(arg_is_unicode) { >                         PyObject *w; >
w = PyUnicode_FromEncodedObject(v, >
Py_FileSystemDefaultEncoding, >
"strict"); >                         if (w != N