Created
November 7, 2017 18:00
-
-
Save mhoffman/8577aa56e39700c270bf8a6b57aefa46 to your computer and use it in GitHub Desktop.
This file contains 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 python | |
### Print the installed location of a python module | |
def pwhichd(): | |
import optparse | |
import os | |
parser = optparse.OptionParser(usage="""%prog <module-name>""") | |
options, args = parser.parse_args() | |
if not args: | |
parser.error('module name expected') | |
module_name = args[0] | |
p = __import__(args[0]) | |
return os.path.dirname(p.__file__) | |
if __name__ == '__main__': | |
print(pwhichd()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment