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 petri.lehtinen
Recipients docs@python, petri.lehtinen, r.david.murray
Date 2011-08-09.12:35:08
SpamBayes Score 1.4141466e-11
Marked as misclassified No
Message-id <1312893309.14.0.812915781754.issue12714@psf.upfronthosting.co.za>
In-reply-to
Content
Yes, but required=True/False makes an *option* required or optional. Setting required=False is not allowed with *positionals*:

>>> import argparse
>>> parser = argparse.ArgumentParser()
>>> parser.add_argument('foo', required=False)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/argparse.py", line 1262, in add_argument
    kwargs = self._get_positional_kwargs(*args, **kwargs)
  File "/usr/lib/python2.7/argparse.py", line 1367, in _get_positional_kwargs
    raise TypeError(msg)
TypeError: 'required' is an invalid argument for positionals

I assume that this is the case that is being documented here, so it should read "options only" meaning "not allowed for positionals". Am I correct?
History
Date User Action Args
2011-08-09 12:35:09petri.lehtinensetrecipients: + petri.lehtinen, r.david.murray, docs@python
2011-08-09 12:35:09petri.lehtinensetmessageid: <1312893309.14.0.812915781754.issue12714@psf.upfronthosting.co.za>
2011-08-09 12:35:08petri.lehtinenlinkissue12714 messages
2011-08-09 12:35:08petri.lehtinencreate