paul j3 added the comment: As to the nature of the error when 'add_subparsers' is given an 'action' parameter:
'add_subparsers' does several things to 'kwargs' before it passes them to the relevant Action class. def add_subparsers(self, **kwargs): # adds 'parser_class' # removes 'title', 'description' (used in an argument group) # add 'prog' parsers_class = self._pop_action_class(kwargs, 'parsers') action = parsers_class(option_strings=[], **kwargs) What I wrote earlier about using the registry is partly wrong. The Action class is determined by either the 'action' parameter or the registry entry. In [17]: p._pop_action_class({}, 'parsers') Out[17]: argparse._SubParsersAction In [18]: p._pop_action_class({'action':'test'}, 'parsers') Out[18]: 'test' So the 'action' parameter works - if you specify a compatible Action class. sp=p.add_subparsers(dest='cmd',action=argparse._SubParsersAction) Such a class must have the same __init__ signature, otherwise you'll get errors such the OP's. It might be worth rewriting the documentation line so this is clearer. Otherwise I recommend closing this issue. action = parsers_class(option_strings=[], **kwargs) ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue23487> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com