I have a python module named LC_cmdline.py
with argparse as follows.
import argparse
import getpass
def get_pass():
return getpass.getpass("Password: ")
def default_pass():
return ''
parser = argparse.ArgumentParser()
parser.add_argument('-u', default='', type=str, metavar='username', dest='username', help="Username for the database")
parser.add_argument('-p', action='store_const', const=get_pass, default=default_pass, dest='get_pass', help="Password for the database")
args = parser.parse_args()
if __name__ == '__main__':
print "username: [%s]"%args.username
print "password: [%s]"%args.get_pass()
I tried to convert it to a documentation by pydoc using the command python -m pydoc -w LC_cmdline
. Then I got this error:
usage: pydoc.py [-h] [-u username] [-p]
pydoc.py: error: unrecognized arguments: -w LC_cmdline
problem in LC_cmdline - <type 'exceptions.SystemExit'>: 2
Is there a way to generate a documentation for a module with arguments like mine by pydoc? Thank you.
BTW, my OS is win7, and my python is 2.7