Created
July 30, 2019 01:18
-
-
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)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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