On Sat, 6 Dec 2008 09:18:47 am Nick Coghlan wrote: > Toshio Kuratomi wrote: > > Guido van Rossum wrote: > >> Glob was just an example. Many use cases for directory traversal > >> couldn't care less if they see *all* files. > > > > Okay. Makes it harder to prove correct or not if I don't know what > > the use case is :-) I can't think of a single use case off-hand. > > > > Even your example of a ??.txt file making retrieval of *.py files > > fail is a little broken. If there was a ??.py file that was > > undecodable the program would most likely want to know that file > > existed. > > Why? Most programs won't be able to do anything with it. But the program can report a sensible error message, so the user can fix the problem. I'd rather have the Python API report errors then silence them, at least by default. I don't suppose it's on the table for functions to grow an extra argument that tells them to skip broken file names and environment variables? What I have in mind is something like: os.listdir(path, silence_errors=False) -> list_of_strings By default, if a filename in path is not a valid string, an exception is raised, with the guilty file name given in bytes as an attribute of the exception. If silence_errors is true, the invalid file names are silently skipped. -- Steven
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