[Python-ideas] Argparse subparsers add required keyword

George Leslie-Waksman waksman at gmail.com
Thu Mar 8 03:47:43 EST 2018

With the stdlib argparse, subparsers can be defined and they can be marked
as required (though this is not documented) but they do not support a
"required" keyword. I think it would make everything more consistent if the
keyword existed.

This won't require any functional changes under the hood.

Right now, this works (and behaves as expected):

parser = argparse.ArgumentParser(...)
subparsers = parser.add_subparsers(...)
subparsers.required = True

but this does not:

parser = argparse.ArgumentParser(...)
subparsers = parser.add_subparsers(..., required=True)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180308/c5601a6a/attachment.html>

More information about the Python-ideas mailing list