Documentation
The documentation for argparse's append action when a default value is provided is unclear
Currently the docs state:
'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:
parser = argparse.ArgumentParser()
parser.add_argument('--foo', action='append')
parser.parse_args('--foo 1 --foo 2'.split())
Namespace(foo=['1', '2'])
However, this documentation does not specify that the default needs to be a list, and cannot be a single value. While this may be obvious in hindsight, a short example would entirely remove this source of confusion.
Linked PRs
Documentation
The documentation for argparse's
appendaction when a default value is provided is unclearCurrently the docs state:
However, this documentation does not specify that the default needs to be a list, and cannot be a single value. While this may be obvious in hindsight, a short example would entirely remove this source of confusion.
Linked PRs
argparse'sappendaction #131389argparse'sappendaction (GH-131389) #139068argparse'sappendaction (GH-131389) #139069