You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The documentation for several of argparse's actions could be improved to be shorter and clearer.
For specific examples:
'store_true' and 'store_false' - These are special cases of 'store_const' used for storing the values True and False respectively. In addition, they create default values of False and True respectively:
The In addition part is clunky.
'append_const' - This stores a list, and appends the value specified by the const keyword argument to the list; note that the const keyword argument defaults to None. The 'append_const' action is typically useful when multiple arguments need to store constants to the same list. For example:
This could be shorter.
'extend' - This stores a list and appends each item from the multi-value argument list to it. The 'extend' action is typically used with the nargs keyword argument value '+' or '*'. Note that when nargs is None (the default) or '?', each character of the argument string will be appended to the list. Example usage:
This sentence feels convoluted
'count' - This counts the number of times a keyword argument occurs. For example, this is useful for increasing verbosity levels:
The argument parsed by argparse is not specifically a keyword argument; this seems like a copy-paste error for the times it's referring to add_argument's args, as opposed to an argument parsed by argparse.
Activity
GH-141963: Clarify argparse documentation (GH-141964)
pythonGH-141963: Clarify argparse documentation (pythonGH-141964)
pythonGH-141963: Clarify argparse documentation (pythonGH-141964)
gpshead commentedon Nov 29, 2025
thanks!
[3.14] GH-141963: Clarify argparse documentation (GH-141964) (#142076)
[3.13] GH-141963: Clarify argparse documentation (GH-141964) (#142077)
pythonGH-141963: Clarify argparse documentation (pythonGH-141964)