Last active
December 17, 2015 20:29
-
-
Save ekimekim/5668398 to your computer and use it in GitHub Desktop.
A shortcut to look up the python online help() for a given module or symbol from a module.
Examples: $ pyman subprocess $ pyman os.path $ pyman sys setprofile $ pyman . open
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 python | |
from sys import argv, exit | |
if len(argv) < 2: | |
print 'USAGE: %s MODULE [SYMBOL]\nOpen help() for given module, or given symbol from module.' % \ | |
argv[0] | |
exit(1) | |
module = argv[1] | |
symbol = argv[2] if len(argv) > 2 else '' | |
if module == '.': module = '' | |
if module: | |
exec 'import %s' % module | |
exec 'subject = %s' % ".".join((module, symbol)).strip('.') | |
help(subject) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment