Why exception from os.path.exists()?
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Fri Jun 1 19:37:04 EDT 2018
On Thu, 31 May 2018 17:43:28 +0000, Grant Edwards wrote:
> Except on the platform in quetion filenames _don't_ contain an embedded
> \0. What was passed was _not_ a path/filename.
"/wibble/rubbish/nobodyexpectsthespanishinquistion" is not a pathname on
my system either, and os.path.exists() returns False for that. As it is
supposed to.
I'd be willing to bet that:
import secrets # Python 3.6+
s = "/" + secrets.token_hex(1024) + "/spam"
is not a pathname on any computer in the world. (If it is even legal.)
And yet os.path.exists(s) returns False.
The maximum number of file components under POSIX is (I believe) 256. And
yet:
py> os.path.exists("/a"*1000000)
False
"/a" by one million cannot possibly be a path under POSIX.
> the thread will continue for months and generate hundreds of followup.
Only because some people insist on exercising their right to be wrong.
--
Steven D'Aprano
"Ever since I learned about confirmation bias, I've been seeing
it everywhere." -- Jon Ronson
More information about the Python-list
mailing list