New submission from gaborbernat <gaborjber...@gmail.com>:
Consider the following code: from argparse import ArgumentParser parser = ArgumentParser() parser.add_argument("--clear-magic", action="store_true") print(parser.parse_args(["--clear"])) parser.add_argument("--clear", action="store_true") print(parser.parse_args(["--clear"])) This has the following output: Namespace(clear_magic=True) Namespace(clear=True, clear_magic=False) I find it surprising and confusing why the clear magic option is accepted when clear is not defined. I'm tempted to say it's a bug. This unstable behaviour is very surprising when iteratively building up the parser. Discovered with https://github.com/pypa/virtualenv/issues/1824#issuecomment-627919033 ---------- messages: 368776 nosy: gaborbernat priority: normal severity: normal status: open title: argparse _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue40615> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com