Skip to content

Instantly share code, notes, and snippets.

@RhetTbull
Created July 30, 2019 01:18
Show Gist options
  • Save RhetTbull/a3b2e914e4fde6a5cc23aef9b1aa061b to your computer and use it in GitHub Desktop.
Save RhetTbull/a3b2e914e4fde6a5cc23aef9b1aa061b to your computer and use it in GitHub Desktop.
Simple command line tool to print path of a given python module (passed as arg on the command line)
#!/usr/bin/env python3
import os
import sys
import importlib
if __name__ == "__main__":
if len(sys.argv) > 1:
modname = sys.argv[1]
try:
module = importlib.import_module(modname)
path = os.path.dirname(module.__file__)
print(path)
except Exception as e:
print(f"{modname}: {e}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment