Skip to content

argparse: add_argument(): error about "const" argument #137988

@val461

Description

@val461

Documentation

I've highlighted the error in bold in the following passage from the doc.

When add_argument() is called with option strings (like -f or --foo) and nargs='?'. This creates an optional argument that can be followed by zero or one command-line arguments. When parsing the command line, if the option string is encountered with no command-line argument following it, the value of const will be assumed to be None instead.

The bold text should be replaced with "used".

Justification: the previous passage is contradicted by the following passage from the same page.

for optional arguments, there is an additional case - the option string is present but not followed by a command-line argument. In this case the value from const will be produced.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    Status

    No status

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions