Message357681
The argparse module incorrectly uses the terms "optional arguments" for keyword arguments.
For instance this argument parser takes a required keyword argument and an optional positional argument, but classifies the former as an "optional argument" and the latter as a "positional argument":
>>> import argparse
>>> parser = argparse.ArgumentParser()
>>> parser.add_argument('--foo', required=True)
_StoreAction(option_strings=['--foo'], dest='foo', nargs=None, const=None, default=None, type=None, choices=None, help=None, metavar=None)
>>> parser.add_argument('bar', nargs='?')
_StoreAction(option_strings=[], dest='bar', nargs='?', const=None, default=None, type=None, choices=None, help=None, metavar=None)
>>> parser.parse_args(['-h'])
usage: [-h] --foo FOO [bar]
positional arguments:
bar
optional arguments:
-h, --help show this help message and exit
--foo FOO
Since the actual classification seems to distinguish positional from keyword arguments instead of required from optional arguments, I think that the "optional arguments:" section should be renamed to "keyword arguments:". |
|
Date |
User |
Action |
Args |
2019-12-01 14:30:00 | maggyero | set | recipients:
+ maggyero, rhettinger, bethard |
2019-12-01 14:30:00 | maggyero | set | messageid: <1575210600.45.0.569419059905.issue38950@roundup.psfhosted.org> |
2019-12-01 14:30:00 | maggyero | link | issue38950 messages |
2019-12-01 14:30:00 | maggyero | create | |
|