[code.view]

[top] / python / PyMOTW / argparse / argparse_long.py

     #!/usr/bin/env python
     # encoding: utf-8
     #
     # Copyright (c) 2010 Doug Hellmann.  All rights reserved.
     #
     """Long option name example.
     """
     #end_pymotw_header
     
     import argparse
     
     parser = argparse.ArgumentParser(description='Example with long option names')
     
     parser.add_argument('--noarg', action="store_true", default=False)
     parser.add_argument('--witharg', action="store", dest="witharg")
     parser.add_argument('--witharg2', action="store", dest="witharg2", type=int)
     
     print parser.parse_args([ '--noarg', '--witharg', 'val', '--witharg2=3' ])
     

[top] / python / PyMOTW / argparse / argparse_long.py

contact | logmethods.com