Message409515
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] |
|
Date |
User |
Action |
Args |
2022-01-02 19:50:38 | lf- | set | recipients:
+ lf- |
2022-01-02 19:50:38 | lf- | set | messageid: <1641153038.74.0.113301629042.issue46228@roundup.psfhosted.org> |
2022-01-02 19:50:38 | lf- | link | issue46228 messages |
2022-01-02 19:50:38 | lf- | create | |
|