On 07-06-18 11:29, Marko Rauhamaa wrote: > Antoon Pardon <antoon.par...@vub.be>: > >> On 07-06-18 05:55, Steven D'Aprano wrote: >>> As a Python programmer, how does treating NUL specially make our life >>> better? >> By treating possible path values differently from impossible path >> values. > There are all kinds of impossibility. The os.stat() reports those > impossibilities via an OSError exception. It's just that > os.path.exists() converts the OSError exception into a False return > value. A ValueError is raised by the Python os.stat() wrapper to > indicate that it can't even deliver the request to the kernel. > > The application programmer doesn't give an iota who determined the > impossibility of a pathname.
So? The fact that the application programmer doesn't give an iota who determined the impossibility of a pathname, doesn't imply he is equally unconcerned about the specific impossibility he ran into. > Unfortunately, os.path.exists() forces the > distinction on the application. No it doesn't. It forces the distinction between two different kinds of impossibilities, but you don't have to care where they originate from. > If I have to be prepared to catch a > ValueError from os.path.exists(), what added value does os.path.exists() > give on top of os.stat()? The whole point of os.path.exists() is > > 1. To provide an operating-system-independent abstraction. > > 2. To provide a boolean interface instead of an exception interface. Mayby trying to provide such an interface is inherently flawed. Answering me a path doesn't exist because of a permission problem is IMO not a good idea. -- Antoon. -- https://mail.python.org/mailman/listinfo/python-list