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 <rep...@bugs.python.org>
<http://bugs.python.org/issue27992>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to