On Tue, Sep 30, 2008 at 8:20 AM, M.-A. Lemburg <[EMAIL PROTECTED]> wrote: > In the end, I think it's better not to be clever and just return > the filenames that cannot be decoded as bytes objects in os.listdir().
Unfortunately that's going to break most code that is using os.listdir(), so it's hardly an improved experience. > Passing those to open() will then open the files as expected, in most > other cases the application will have to provide explicit conversions > in whatever way best fits the application. In most cases the app will try to concatenate a pathname given as a string and then it will fail. > Also note that os.listdir() isn't the only source of filesnames. You > often read them from a file, a database, some socket, etc, so letting > the application decide what to do is not asking too much, IMHO. In all those cases, the code that reads them is responsible for picking an encoding or relying on a default encoding, and the resulting filenames are always expressed as text, not bytes. I don't think it's the same at all. -- --Guido van Rossum (home page: http://www.python.org/~guido/) _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com