PyDocs

Nav

Command-line interface libraries

ArgumentParser.set_defaults

  • ArgumentParser.set_defaults(**kwargs)
Most of the time, the attributes of the object returned by parse_args() will be fully determined by inspecting the command-line arguments and the argument actions. set_defaults() allows some additional attributes that are determined without any inspection of the command line to be added:
1 Example
>>> parser = argparse.ArgumentParser()
>>> parser.add_argument('foo', type=int)
>>> parser.set_defaults(bar=42, baz='badger')
>>> parser.parse_args(['736'])
Namespace(bar=42, baz='badger', foo=736)
from the Python docs
See Also
No see-alsos for argparse/ArgumentParser.set_defaults
0 Notes
No notes for ArgumentParser.set_defaults