Skip to content

Instantly share code, notes, and snippets.

@AbirRazzak
Created June 18, 2021 19:06
Show Gist options
  • Save AbirRazzak/94375f4659c91d52a224683a5f3d2d90 to your computer and use it in GitHub Desktop.
Save AbirRazzak/94375f4659c91d52a224683a5f3d2d90 to your computer and use it in GitHub Desktop.
Get All Modules in Python Project
def get_py_modules():
modules = []
path = 'some/path'
path_walk = os.walk(path)
_, dirs, _ = next(path_walk)
for module_dir in dirs:
if os.path.exists(os.path.join(path, module_dir, '__init__.py')):
modules.append(module_dir)
modules.sort()
pass # do stuff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment