[Python-Dev] Updates to PEP 471, the os.scandir() proposal (original) (raw)

Ben Hoyt benhoyt at gmail.com
Tue Jul 8 22:09:36 CEST 2014


I think you're misunderstanding isdir() and isfile(), as these don't actually call os.stat(). All DirEntry methods either call nothing or os.lstat() to get the stat info on the entry itself (not the destination of the symlink).

Oh. Extract of your PEP: "isdir(): like os.path.isdir(), but much cheaper". genericpath.isdir() and genericpath.isfile() use os.stat(), whereas posixpath.islink() uses os.lstat(). Is it a mistake in the PEP?

Ah, you're dead right -- this is basically a bug in the PEP, as DirEntry.is_dir() is not like os.path.isdir() in that it is based on the entry itself (like lstat), not following the link.

I'll improve the wording here and update the PEP.

-Ben



More information about the Python-Dev mailing list