Message239268
OK, so you are thinking about what happens to the subparsers `dest` when the user names a command. That isn't handled by the `store` action, but by the call of the subparsers action
class _SubParsersAction(Action):
....
def __call__
....
# set the parser name if requested
if self.dest is not SUPPRESS:
setattr(namespace, self.dest, parser_name)
...
namespace, arg_strings = parser.parse_known_args(arg_strings, namespace)
Storing the parser_name is a minor part of this action. The important, distinctive part is passing the parsing action to that subparser.
That storing could be done in an append way, but why? There can only one `subparsers`, and it can be invoked only once.
None of the existing Action classes can replace _SubParsersAction, which is entered in the `registry` as `parsers`:
In [11]: parser._registry_get('action','parsers')
Out[11]: argparse._SubParsersAction
If you want to write your own version of this action, you can use it, either by replacing the existing class, or by changing this registry entry. |
|
Date |
User |
Action |
Args |
2015-03-25 16:23:57 | paul.j3 | set | recipients:
+ paul.j3, berker.peksag, derks, spaceone |
2015-03-25 16:23:56 | paul.j3 | set | messageid: <1427300636.98.0.928900497665.issue23487@psf.upfronthosting.co.za> |
2015-03-25 16:23:56 | paul.j3 | link | issue23487 messages |
2015-03-25 16:23:56 | paul.j3 | create | |
|