Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@malcolmgreaves
Created December 19, 2018 08:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save malcolmgreaves/11101fb34debec372661aec98666f70a to your computer and use it in GitHub Desktop.
Save malcolmgreaves/11101fb34debec372661aec98666f70a to your computer and use it in GitHub Desktop.
List all files in directory.
import os
def list_files(directory: str) -> Iterable[str]:
for dirpath, dirnames, filenames in os.walk(directory):
for f in filenames:
fpath = os.path.join(dirpath, f)
if os.path.isfile(fpath):
yield fpath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment