This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author maggyero
Recipients bethard, maggyero, rhettinger
Date 2019-12-01.14:30:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1575210600.45.0.569419059905.issue38950@roundup.psfhosted.org>
In-reply-to
Content
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:".
History
Date User Action Args
2019-12-01 14:30:00maggyerosetrecipients: + maggyero, rhettinger, bethard
2019-12-01 14:30:00maggyerosetmessageid: <1575210600.45.0.569419059905.issue38950@roundup.psfhosted.org>
2019-12-01 14:30:00maggyerolinkissue38950 messages
2019-12-01 14:30:00maggyerocreate