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

"Martin v. Löwis" martin at v.loewis.de
Mon Nov 20 00:07:26 CET 2006


gabor schrieb:
> 1. simply fix the documentation, and state that if the file-name cannot
> be decoded into unicode, then it's returned as byte-string. 

For 2.5, this should be done. Contributions are welcome.

[...then]
> [os.path.join(path,n) for n in os.listdir(path)]
> 
> will not work.
> 
> 2. add support for some unicode-decoding flags, like i wrote before

I may have missed something, but did you present a solution that would
make the case above work?

> 3. some solution.

One approach I had been considering is to always make the decoding
succeed, by using the private-use-area of Unicode to represent bytes
that don't decode correctly.

Regards,
Martin



More information about the Python-list mailing list