gh-65169: Clarify prog default in argparse (GH-31602)

This commit is contained in:
Stanley 2024-09-24 03:57:37 -07:00 committed by GitHub
parent e670a113b5
commit e69ff34e81
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 4 deletions

View File

@ -249,11 +249,12 @@ The following sections describe how each of these are used.
prog prog
^^^^ ^^^^
By default, :class:`ArgumentParser` objects use ``sys.argv[0]`` to determine By default, :class:`ArgumentParser` objects use the base name
(see :func:`os.path.basename`) of ``sys.argv[0]`` to determine
how to display the name of the program in help messages. This default is almost how to display the name of the program in help messages. This default is almost
always desirable because it will make the help messages match how the program was always desirable because it will make the help messages match the name that was
invoked on the command line. For example, consider a file named used to invoke the program on the command line. For example, consider a file
``myprogram.py`` with the following code:: named ``myprogram.py`` with the following code::
import argparse import argparse
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()