Created
July 5, 2018 22:51
-
-
Save mhoffman/39c70859e8160409829e9699169cbf35 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