Why exception from os.path.exists()?

Paul Moore p.f.moore at gmail.com
Fri Jun 1 11:02:58 EDT 2018


On 1 June 2018 at 15:38, Grant Edwards <grant.b.edwards at gmail.com> wrote:
> On 2018-06-01, Paul Moore <p.f.moore at gmail.com> wrote:
>
>> Python allows strings with embedded \0 characters, so it's possible
>> to express that question in Python - os.path.exists('a\0b').  What
>> can be expressed in terms of the low-level (C-based) operating
>> system API shouldn't be relevant.
>
> Python allows floating point numbers, so it is possible to express
> this question in python: os.path.exists(3.14159).  Is the fact that
> the underlying OS/filesystem can't identify files via a floating point
> number relevent?  Should it return False or raise ValueError?

I'm not sure if you're asking a serious question here, or trying to
make some sort of point, but os.path.exists is documented as taking a
string, so passing a float should be a TypeError. And it is.

But as I already said, this is a huge amount of effort spent on a
pretty trivial corner case, so I'll duck out of this thread now.
Paul



More information about the Python-list mailing list