mirror of
https://github.com/python/cpython.git
synced 2025-12-23 09:19:18 +00:00
[3.13] GH-139067: Add example for argparse's append action (GH-131389) (#139069)
Some checks are pending
Tests / (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Android (aarch64) (push) Blocked by required conditions
Tests / Android (x86_64) (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Sanitizers (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
Some checks are pending
Tests / (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Android (aarch64) (push) Blocked by required conditions
Tests / Android (x86_64) (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / Sanitizers (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
GH-139067: Add example for `argparse`'s `append` action (GH-131389)
(cherry picked from commit 101fd33065)
Co-authored-by: Moshe Kaplan <mosheekaplan@gmail.com>
This commit is contained in:
parent
5f84c1d192
commit
fa6dbb1641
1 changed files with 7 additions and 7 deletions
|
|
@ -687,16 +687,16 @@ how the command-line arguments should be handled. The supplied actions are:
|
|||
>>> parser.parse_args('--foo --bar'.split())
|
||||
Namespace(foo=True, bar=False, baz=True)
|
||||
|
||||
* ``'append'`` - This stores a list, and appends each argument value to the
|
||||
list. It is useful to allow an option to be specified multiple times.
|
||||
If the default value is non-empty, the default elements will be present
|
||||
in the parsed value for the option, with any values from the
|
||||
command line appended after those default values. Example usage::
|
||||
* ``'append'`` - This appends each argument value to a list.
|
||||
It is useful for allowing an option to be specified multiple times.
|
||||
If the default value is a non-empty list, the parsed value will start
|
||||
with the default list's elements and any values from the command line
|
||||
will be appended after those default values. Example usage::
|
||||
|
||||
>>> parser = argparse.ArgumentParser()
|
||||
>>> parser.add_argument('--foo', action='append')
|
||||
>>> parser.add_argument('--foo', action='append', default=['0'])
|
||||
>>> parser.parse_args('--foo 1 --foo 2'.split())
|
||||
Namespace(foo=['1', '2'])
|
||||
Namespace(foo=['0', '1', '2'])
|
||||
|
||||
* ``'append_const'`` - This stores a list, and appends the value specified by
|
||||
the const_ keyword argument to the list; note that the const_ keyword
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue