summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/argparse.rst5
-rw-r--r--Doc/whatsnew/3.7.rst4
2 files changed, 8 insertions, 1 deletions
diff --git a/Doc/library/argparse.rst b/Doc/library/argparse.rst
index a8aeca4..00115d5 100644
--- a/Doc/library/argparse.rst
+++ b/Doc/library/argparse.rst
@@ -1636,7 +1636,7 @@ Sub-commands
stored; by default ``None`` and no value is stored
* required_ - Whether or not a subcommand must be provided, by default
- ``False``.
+ ``False`` (added in 3.7)
* help_ - help for sub-parser group in help output, by default ``None``
@@ -1792,6 +1792,9 @@ Sub-commands
>>> parser.parse_args(['2', 'frobble'])
Namespace(subparser_name='2', y='frobble')
+ .. versionchanged:: 3.7
+ New *required* keyword argument.
+
FileType objects
^^^^^^^^^^^^^^^^
diff --git a/Doc/whatsnew/3.7.rst b/Doc/whatsnew/3.7.rst
index af7e22d..1ec8e0c 100644
--- a/Doc/whatsnew/3.7.rst
+++ b/Doc/whatsnew/3.7.rst
@@ -2401,6 +2401,10 @@ Changes in the Python API
instead of a :class:`bytes` instance.
(Contributed by Victor Stinner in :issue:`21071`.)
+* :mod:`argparse` subparsers can now be made mandatory by passing ``required=True``
+ to :meth:`ArgumentParser.add_subparsers() <argparse.ArgumentParser.add_subparsers>`.
+ (Contributed by Anthony Sottile in :issue:`26510`.)
+
* :meth:`ast.literal_eval()` is now stricter. Addition and subtraction of
arbitrary numbers are no longer allowed.
(Contributed by Serhiy Storchaka in :issue:`31778`.)