[Python-Dev] Python-3.0, unicode, and os.environ (original) (raw)

Anders J. Munch ajm at flonidan.dk
Tue Dec 9 12:04:48 CET 2008


M.-A. Lemburg wrote:

Well, this is not too far away from just putting the whole decoding logic into the application directly: files = [filename.decode(filesystemencoding, errors='warnreplace') for filename in os.listdir(dir)] (or os.listdirb() if that's where the discussion is heading)

I see what you mean, and yes, I think os.listdirb will do just as well. There is no need for any extra parameters to os.listdir. The typical application will just obliviously use os.listdir(dir) and get the default elide-and-warn behaviour for un-decodable names. That rare special application that needs more control can use os.listdirb and handle decoding itself.

Using a global registry of error handlers would just get in the way of an application that needs more control.



More information about the Python-Dev mailing list