May-05-2021, 09:36 AM
(This post was last modified: May-05-2021, 09:36 AM by Gribouillis.)
This example is taken verbatim from the documentation of os.scandir(). It prints the names of all entries in a directory which are files and which names don't start with a dot.
with os.scandir(path) as it: for entry in it: if not entry.name.startswith('.') and entry.is_file(): print(entry.name)