[issue27992] In the argparse there is a misleading words about %(prog)s value
New submission from py.user: 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]. ---------- assignee: docs@python components: Documentation, Library (Lib) files: argparse_sys-argv-0-part.diff keywords: patch messages: 274729 nosy: docs@python, py.user priority: normal severity: normal status: open title: In the argparse there is a misleading words about %(prog)s value type: behavior versions: Python 3.6 Added file: http://bugs.python.org/file44420/argparse_sys-argv-0-part.diff _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue27992> _______________________________________
Karthikeyan Singaravelan <tir.karthi@gmail.com> added the comment: 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/62f9588663ebfea1735e9d142ef527395a6c2... ---------- nosy: +paul.j3, xtreak title: 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 default versions: +Python 3.7, Python 3.8 -Python 3.6 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue27992> _______________________________________
py.user <bugzilla-mail-box@yandex.ru> added the comment: @Karthikeyan Singaravelan Thank you for the point. I added a new patch. ---------- Added file: https://bugs.python.org/file48245/argparse_sys-argv-0-basename.diff _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue27992> _______________________________________
Karthikeyan Singaravelan <tir.karthi@gmail.com> added the comment: CPython now accepts GitHub PRs. Please see the workflow at https://devguide.python.org . You can raise a PR against master branch. ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue27992> _______________________________________
Change by py.user <bugzilla-mail-box@yandex.ru>: ---------- pull_requests: +12642 stage: -> patch review _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue27992> _______________________________________
Change by Karthikeyan Singaravelan <tir.karthi@gmail.com>: ---------- nosy: +rhettinger _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue27992> _______________________________________
participants (2)
-
Karthikeyan Singaravelan
-
py.user