Message141816
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? |
|
Date |
User |
Action |
Args |
2011-08-09 12:35:09 | petri.lehtinen | set | recipients:
+ petri.lehtinen, r.david.murray, docs@python |
2011-08-09 12:35:09 | petri.lehtinen | set | messageid: <1312893309.14.0.812915781754.issue12714@psf.upfronthosting.co.za> |
2011-08-09 12:35:08 | petri.lehtinen | link | issue12714 messages |
2011-08-09 12:35:08 | petri.lehtinen | create | |
|