Why exception from os.path.exists()?
Antoon Pardon
antoon.pardon at vub.be
Mon Jun 11 03:55:06 EDT 2018
On 11-06-18 02:28, Steven D'Aprano wrote:
> On Sun, 10 Jun 2018 22:09:39 +0100, Barry Scott wrote:
>
>> Singling out os.path.exists as a special case I do think is reasonable.
>> All functions that take paths need to have a consistent response to data
> The *mere existence* of os.path.exists means that there is not a
> consistent response to file names:
>
> open(foo) raises an exception if foo doesn't exist;
>
> os.path.exists(foo) returns False if foo doesn't exist.
That is not correct. The path can exist and os.path.exists still return False.
> There is no requirement that different functions do the same thing with
> the same bad input. The *whole point* of o.p.exists is to return False,
> not raise an exception.
And the price is that it will not always give the correct answer.
--
Antoon Pardon.
More information about the Python-list
mailing list