Skip to content

Instantly share code, notes, and snippets.

@ekimekim
Last active December 17, 2015 20:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ekimekim/5668398 to your computer and use it in GitHub Desktop.
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
#!/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