PyDocs

Nav

Generic Operating System Services

scandir

os

function · Added in 3.5
  • scandir(path='.')
Return an iterator of DirEntry objects for given path.

path can be specified as either str, bytes, or a path-like object.  If
path is bytes, the names of yielded DirEntry objects will also be bytes;
in all other circumstances they will be str.

If path is None, uses the path='.'.
Changed in 3.6, 3.7, 3.15
  • 3.6: Added support for the context manager protocol and the close() method. If a scandir() iterator is neither exhausted nor explicitly closed a ResourceWarning will be emitted in its destructor. The function accepts a path-like object.
  • 3.7: Added support for file descriptors on Unix.
  • 3.15: os.scandir(-1) now fails with OSError(errno.EBADF) rather than listing the current directory.
Members of scandir

c

close
Close the iterator and free acquired resources.
0 Examples
No examples for os/scandir.
See Also
No see-alsos for os/scandir
0 Notes
No notes for scandir