On Tue, Sep 30, 2008 at 8:20 AM, M.-A. Lemburg <mal at egenix.com> 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/)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4