Saturday, 15 March 2014

python - How to get available flags out of an ArgumentParser object? -



python - How to get available flags out of an ArgumentParser object? -

i'm using argparse module python project. i'm looking available flags out of argumentparser object before calling parse_args(). have ideas?

got source code of add_argument():

>>> import argparse >>> parser = argparse.argumentparser() >>> parser.add_argument('-v', '--verbosity', help='more debug info', action='store_true') _storetrueaction(option_strings=['-v', '--verbosity'], dest='verbosity', nargs=0, const=true, default=false, type=none, choices=none, help='more debug info', metavar=none) >>> parser._option_string_actions.keys() ['-v', '-h', '--verbosity', '--help'] >>>

python command-line-arguments argparse

No comments:

Post a Comment