[Python-Dev] PEP 471 (scandir): Add a new DirEntry.inode() method?

Victor Stinner victor.stinner at gmail.com
Sat Feb 14 12:17:11 CET 2015


2015-02-14 11:57 GMT+01:00 Victor Stinner <victor.stinner at gmail.com>:
> I propose something else: a DirEntry.inode read-only property (...)

Full DirEntry API:

- name (str) attribute
- path (str) read-only property, created at the first call
- inode (int or None) attribute <=== my proposition
- is_dir(*, follow_symlinks=True)
- is_file(*, follow_symlinks=True)
- is_symlink(*, follow_symlinks=True)
- stat(*, follow_symlinks=True)

is_dir(), is_file(), is_symlink() and stat() are method because they
may all require a syscall (os.stat or os.lstat). They all cache their
result. In some cases, the result is already known when DirEntry is
created. In most cases, a single call to os.stat() is required to fill
the result of all methods.

Victor


More information about the Python-Dev mailing list