This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author lf-
Recipients lf-
Date 2022-01-02.19:50:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1641153038.74.0.113301629042.issue46228@roundup.psfhosted.org>
In-reply-to
Content
Currently the documentation for argparse.ArgumentParser states that the default value of the prog[ram] argument is argv[0], however, this does not match the actual behaviour of the constructor. In reality, the constructor uses the basename of argv[0], as can be seen in the code here: https://github.com/python/cpython/blob/e800dd1793dafbc4114da744f605731ff6630623/Lib/argparse.py#L1733-L1735

Here is a demo:

/tmp » cat test.py
import argparse

ap = argparse.ArgumentParser()
print(ap.prog)
ap.print_usage()
/tmp » python test.py
test.py
usage: test.py [-h]
/tmp » python ./test.py
test.py
usage: test.py [-h]
/tmp » mkdir test
/tmp » cd test
/tmp/test » python ../test.py
test.py
usage: test.py [-h]
History
Date User Action Args
2022-01-02 19:50:38lf-setrecipients: + lf-
2022-01-02 19:50:38lf-setmessageid: <1641153038.74.0.113301629042.issue46228@roundup.psfhosted.org>
2022-01-02 19:50:38lf-linkissue46228 messages
2022-01-02 19:50:38lf-create