On this page
posix.DirEntry
Prev: posix.device_encoding | Up: posix | Next: posix.dup
Rel: posix.abort, posix.access, posix.chdir, posix.chflags
Ref: docs.python.org — posix.DirEntry
Tags: #public #python3 #stdlib #posix
Import
import posix
from posix import DirEntry
Signature & Overview
posix.DirEntry()
posix.DirEntry class.
Methods & Attributes
DirEntry.inode(self, /)— Return inode of the entry; cached per entry.DirEntry.is_dir(self, /, *, follow_symlinks=True)— Return True if the entry is a directory; cached per entry.DirEntry.is_file(self, /, *, follow_symlinks=True)— Return True if the entry is a file; cached per entry.DirEntry.is_junction(self, /)— Return True if the entry is a junction; cached per entry.DirEntry.is_symlink(self, /)— Return True if the entry is a symbolic link; cached per entry.DirEntry.stat(self, /, *, follow_symlinks=True)— Return stat_result object for the entry; cached per entry.
Usage
import os
with os.scandir('.') as it:
first = next(it, None)
assert first is None or isinstance(first, os.DirEntry)
Gotchas
- Import via
os.DirEntry: Directimport posixfails on Windows.
REPL Inspect
from posix import DirEntry
help(DirEntry)
Linked from
Related notes
- tuts/python3/stdlib_module/posix/device_encoding Linked here; links to this page; shared tags: #posix, #stdlib
- tuts/python3/stdlib_module/posix/dup Linked here; links to this page; shared tags: #posix, #stdlib
- tuts/python3/stdlib_module/posix Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/posix/abort Linked here; shared tags: #posix, #stdlib
- tuts/python3/stdlib_module/posix/access Linked here; shared tags: #posix, #stdlib
- tuts/python3/stdlib_module/posix/chdir Linked here; shared tags: #posix, #stdlib
- tuts/python3/stdlib_module/posix/chflags Linked here; shared tags: #posix, #stdlib
- tuts/python3/stdlib_module/posix/chmod shared tags: #posix, #stdlib
- tuts/python3/stdlib_module/posix/chown shared tags: #posix, #stdlib
- tuts/python3/stdlib_module/posix/chroot shared tags: #posix, #stdlib