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.
Created on 2011年08月09日 11:54 by petri.lehtinen, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (4) | |||
|---|---|---|---|
| msg141812 - (view) | Author: Petri Lehtinen (petri.lehtinen) * (Python committer) | Date: 2011年08月09日 11:54 | |
The documentation of argparse.ArgumentParser.add_argument() says: * required - Whether or not the command-line option may be omitted (optionals only). I believe it should be "options only" instead of "optionals only". |
|||
| msg141815 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2011年08月09日 12:24 | |
Nope, optionals is what argparse calls them. |
|||
| msg141816 - (view) | Author: Petri Lehtinen (petri.lehtinen) * (Python committer) | Date: 2011年08月09日 12:35 | |
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?
|
|||
| msg141865 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2011年08月10日 14:38 | |
"optionals only" means the same thing as "options only", but 'optionals' is what argparse calls them (as contrasted with positionals).
'optionals' is only used two places in the doc and isn't defined, but its meaning is implied by the section heading ("optional arguments").
|
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:20 | admin | set | github: 56923 |
| 2011年08月10日 14:38:40 | r.david.murray | set | messages: + msg141865 |
| 2011年08月09日 12:35:08 | petri.lehtinen | set | messages: + msg141816 |
| 2011年08月09日 12:24:36 | r.david.murray | set | status: open -> closed nosy: + r.david.murray messages: + msg141815 resolution: not a bug stage: resolved |
| 2011年08月09日 11:54:12 | petri.lehtinen | create | |