[code.view]

[top] / python / PyMOTW / optparse / optparse_short.py

     #!/usr/bin/env python
     #
     # Copyright 2007 Doug Hellmann.
     """Using optparse with single-letter options.
     """
     #end_pymotw_header
     
     import optparse
     
     parser = optparse.OptionParser()
     parser.add_option('-a', action="store_true", default=False)
     parser.add_option('-b', action="store", dest="b")
     parser.add_option('-c', action="store", dest="c", type="int")
     
     print parser.parse_args(['-a', '-bval', '-c', '3'])
     

[top] / python / PyMOTW / optparse / optparse_short.py

contact | logmethods.com