[issue14856] argparse: creating an already defined subparsers does not raises an exception

Steven Bethard report at bugs.python.org
Sun Jul 22 00:29:29 CEST 2012


Steven Bethard <steven.bethard at gmail.com> added the comment:

Yeah, overwriting the existing parser is probably not typically what the user intended.

However, I could see someone doing this if, say, they had a parser designed by another module writer, and they wanted to use it but just change one of the sub-parsers or something like that. But a "set_parser" method would probably make more sense for this use case than "add_parser".

I guess my recommendation is to add a "set_parser" method that replaces the old parser (like "add_parser" does now), and then issue deprecation warnings in "add_parser" if a parser with the given name is present (like the patch does, but with deprecation warnings instead of exceptions).

We could then turn the warnings into errors in a few releases.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14856>
_______________________________________


More information about the Python-bugs-list mailing list