Why exception from os.path.exists()?

Gregory Ewing greg.ewing at canterbury.ac.nz
Thu May 31 10:14:58 EDT 2018


Chris Angelico wrote:

> A Unix path name cannot contain a null byte, so what you have is a
> fundamentally invalid name. ValueError is perfectly acceptable.

It would also make sense for it could simply return False, since
a file with such a name can't exist.

This is analogous to the way comparing objects of different types
for equality returns False instead of raising an exception.

-- 
Greg



More information about the Python-list mailing list