[issue13540] Document the Action API in argparse
paul j3
report at bugs.python.org
Sun Aug 24 07:14:28 CEST 2014
paul j3 added the comment:
While we are talking the Action class, the documentation isn't clear that the 'add_argument' method returns an Action object, specifically one the subclasses. More than once, when answering Stackoverflow questions I've recommended assigning this object to a variable for use later in the script.
a = parser.add_argument(...)
...
print a.dest
a.help = 'change the help'
a.required = True
...
The doc mentions that 'add_subparsers' 'returns a special action object.'
In sum, I think the documentation needs a sentence or two that describe what add_argument returns. I'm less sure whether it should include an example of using that return.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13540>
_______________________________________
More information about the Python-bugs-list
mailing list