File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1371,12 +1371,14 @@ argument::
13711371 >>> parser.parse_args(['--', '-f'])
13721372 Namespace(foo='-f', one=None)
13731373
1374+ .. _prefix-matching :
13741375
1375- Argument abbreviations
1376- ^^^^^^^^^^^^^^^^^^^^^^
1376+ Argument abbreviations (prefix matching)
1377+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
13771378
13781379The :meth: `~ArgumentParser.parse_args ` method allows long options to be
1379- abbreviated if the abbreviation is unambiguous::
1380+ abbreviated to a prefix, if the abbreviation is unambiguous (the prefix matches
1381+ a unique option)::
13801382
13811383 >>> parser = argparse.ArgumentParser(prog='PROG')
13821384 >>> parser.add_argument('-bacon')
@@ -1852,6 +1854,12 @@ the populated namespace and the list of remaining argument strings.
18521854 >>> parser.parse_known_args(['--foo', '--badger', 'BAR', 'spam'])
18531855 (Namespace(bar='BAR', foo=True), ['--badger', 'spam'])
18541856
1857+ .. warning ::
1858+ :ref: `Prefix matching <prefix-matching >` rules apply to
1859+ :meth: `parse_known_args `. The parser may consume an option even if it's just
1860+ a prefix of one of its known options, instead of leaving it in the remaining
1861+ arguments list.
1862+
18551863
18561864Customizing file parsing
18571865^^^^^^^^^^^^^^^^^^^^^^^^
You can’t perform that action at this time.
0 commit comments