Issue27992
Created on 2016-09-07 03:10 by py.user, last changed 2022-04-11 14:58 by admin.
Pull Requests |
|
|
|
URL |
Status |
Linked |
Edit |
PR 12717 |
open |
py.user,2019-04-07 15:27 |
|
Messages (4) |
|
|
msg274729 - (view) |
Author: py.user (py.user) * |
Date: 2016-09-07 03:10 |
https://docs.python.org/3/library/argparse.html#argumentparser-objects "prog - The name of the program (default: sys.argv[0])" It doesn't take all sys.argv[0]. It splits sys.argv[0] and takes only the trailing part. An example: a.py #!/usr/bin/env python3 import argparse import sys parser = argparse.ArgumentParser() parser.add_argument("arg", help="The name is %(prog)s, the sys.argv[0] is " + sys.argv[0]) args = parser.parse_args() The output in the console: [guest@localhost bugs]$ ../bugs/a.py -h usage: a.py [-h] arg positional arguments: arg The name is a.py and sys.argv[0] is ../bugs/a.py optional arguments: -h, --help show this help message and exit [guest@localhost bugs]$ In the output we see that %(prog)s takes only trailing part of sys.argv[0] not all. Applied a patch to the issue that specifies about part of sys.argv[0]. |
|
|
msg339287 - (view) |
Author: Karthikeyan Singaravelan (xtreak) *  |
Date: 2019-04-01 09:27 |
Thanks for the report. To be little more clear it returns the "basename of sys.argv[0]" at [0] than the attached patch that says "uses part of ``sys.argv[0]``" . [0] https://github.com/python/cpython/blob/62f9588663ebfea1735e9d142ef527395a6c2b95/Lib/argparse.py#L1638 |
|
|
msg339557 - (view) |
Author: py.user (py.user) * |
Date: 2019-04-07 06:46 |
@Karthikeyan Singaravelan Thank you for the point. I added a new patch. |
|
|
msg339558 - (view) |
Author: Karthikeyan Singaravelan (xtreak) *  |
Date: 2019-04-07 06:48 |
CPython now accepts GitHub PRs. Please see the workflow at https://devguide.python.org . You can raise a PR against master branch. |
|
|
History |
|
|
|
Date |
User |
Action |
Args |
2022-04-11 14:58:35 |
admin |
set |
github: 72179 |
2019-10-24 08:47:12 |
xtreak |
set |
nosy: + rhettinger |
2019-04-07 15:27:29 |
py.user |
set |
stage: patch reviewpull_requests: + <pull%5Frequest12642> |
2019-04-07 06:48:42 |
xtreak |
set |
messages: + |
2019-04-07 06:46:19 |
py.user |
set |
files: + argparse_sys-argv-0-basename.diffmessages: + |
2019-04-01 09:27:07 |
xtreak |
set |
nosy: + paul.j3, xtreaktitle: In the argparse there is a misleading words about %(prog)s value -> Clarify %(prog)s in argparse help formatter returns basename of sys.argv[0] by defaultmessages: + versions: + Python 3.7, Python 3.8, - Python 3.6 |
2016-09-07 03:10:52 |
py.user |
create |
|