Toshio Kuratomi wrote:

  - If this is true, a definition of os.listdir(<type 'str'>) that would
better meet programmer expectation would be: "Give me all files in a
directory with the output as str type".  The definition of
os.listdir(<type 'bytes'>) would be "Give me all files in a directory
with the output as bytes type".  Raising an exception when the filenames
are undecodable is perfectly reasonable in this situation.

Your examples (snipped) pretty well convince me that there is a use case for raising exceptions. We should move beyond arguing over which one way is right. I think there should be a second argument 'ignorebad=False' to ignore undecodable files rather than raise the exception (or 'strict=True' to stop and raise exception on non-decodable names -- then code is 'if strict: raise ...'). I believe other functions have a similar parameter.

tjr

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to