Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"If you are afraid of loneliness, don't marry." -- Chekhov


devel / comp.lang.python / Add angle brackets for required args in argparse

SubjectAuthor
* Add angle brackets for required args in argparsescruel tao
`* Re: Add angle brackets for required args in argparseMark Bourne
 `- Re: Add angle brackets for required args in argparsescruel tao

1
Add angle brackets for required args in argparse

<mailman.1832.1676481401.20444.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21702&group=comp.lang.python#21702

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!weretis.net!feeder8.news.weretis.net!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: scru...@hotmail.com (scruel tao)
Newsgroups: comp.lang.python
Subject: Add angle brackets for required args in argparse
Date: Wed, 15 Feb 2023 07:33:37 +0000
Lines: 10
Message-ID: <mailman.1832.1676481401.20444.python-list@python.org>
References: <OSZP286MB0742B742ED736B07B5665A9DA5DD9@OSZP286MB0742.JPNP286.PROD.OUTLOOK.COM>
<OS3P286MB0740CCCB1D94B91E01BB4B79A5A39@OS3P286MB0740.JPNP286.PROD.OUTLOOK.COM>
Mime-Version: 1.0
Content-Type: text/plain; charset="gb2312"
Content-Transfer-Encoding: base64
X-Trace: news.uni-berlin.de pGAvFYVmKTr8ENQN0ssc8A5+1X86DaTcXWRNpV46BSeQ==
Return-Path: <scruelt@hotmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=hotmail.com header.i=@hotmail.com header.b=QIJX68IR;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.061
X-Spam-Evidence: '*H*': 0.89; '*S*': 0.01; 'message:': 0.03;
'subject:Add': 0.04; 'error:': 0.05; 'arguments': 0.16;
'subject:required': 0.16; 'to:addr:python-list': 0.20; 'run':
0.23; 'to:name:python-list@python.org': 0.24; 'error': 0.29;
'subject:for': 0.33; 'there': 0.33; 'path': 0.33; 'header:In-
Reply-To:1': 0.34; 'following': 0.35; 'url-ip:13.107/16': 0.38;
'way': 0.38; 'provide': 0.60; 'let': 0.66; 'url-ip:104.18/16':
0.67; 'following:': 0.69; 'charset:gb2312': 0.70; 'skip:a 40':
0.70; 'style,': 0.91
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
b=l8OfS0s+MZ63X4or4axewwm2RS0dPasiNyasNcJ1XC4trPqvawBE/uFUJFeQRZX3+HYlzSlU4IhZiGkIEjqNXT+cXGTdMIZM+Zr36LwE4QwcTS/mITk9ROdiYMPP+CtLnzMPMbF1LWXbg8YLtfVhZA/EV5QFdEBLh5vMqWfEXyMtPAkzyKuUWUeATwfOfycQ0TfUxUB0K9YX51EtroWnHa3R2uFbLgfgpyhmcEPgFfC/HnYzg5nCC3ayCuSkj8Yhb8p+JejSYk3H7kViB5LA1r/3bv6bpjQW7ikQGFc8s5O/gJrHYIX30Vw8QZJCH9rm/8fCdnKyuqFSZknCII8GFA==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
s=arcselector9901;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
bh=Rdh2MDlFnDiju++yDMNp/DJDLce45ZcCO2g/O9CncOw=;
b=BkgpiSELa4ebsp5JKGiBZFfvLnW6Jhp9+kQ+LLVVe5fVWbZETV2QMWa37w7UYzSJn/KBM0/aEjvgv7agJj9lZloNZZ6428OqCxGEY8gzVYGCi0kaS3iJb7WrYBBQdUPeOwUrBBv2nQYoiMWB8BhMEiCpi8h7+XvpXLdOk4fg/whBCtAw++/ZYO3sFmZCEdE0QaOsT89eyCU0iATLYk2hQVsL0W7pPzQY1D8XIk8rz0/4VgJsjOYooHvRbzZCHMI4xgcreA1Djl/TfOGgdmytVmNAQ7k9UE20pI+o4/ki7yksh7Q7apPPLHO8yjPeE53RzrditwfoO2FgShHwlcmm9Q==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none;
dkim=none; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com;
s=selector1;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
bh=Rdh2MDlFnDiju++yDMNp/DJDLce45ZcCO2g/O9CncOw=;
b=QIJX68IR48Ywrid/FsjVfNY1HyALCU/ddk9Cw0kHi3TmJm91uBL3LvoLIGx1TlhpNMMOBKH8agmJ1Y4QL/9MBLeBwnwvkJMD3LepysC1Zp23Cp6K4E0Erb9K0qVmq8Q0hBixuadV4TocRyvQXJFQ8wz7oK4UMEHx/WNvN0hMin0dmScURFnuePvSiu6jnMOFYkocvbatErns967nQ7rNs0J+Tew3pGE6QYnDWN0bWkpIvm11ZZtwgNiH9VxeNnTDY10Lr2QluyYIAwwcz+EdfioNpKSqOuuK4dWgTUbbjWjw16ddbc1MNoE8TUbrj1gW4TknSjeDE0LTwFct6dSruQ==
Thread-Topic: Add angle brackets for required args in argparse
Thread-Index: AQHZP4dtNgofviXt8U+xP9Q6+m5xNq7PoH/g
In-Reply-To: <OSZP286MB0742B742ED736B07B5665A9DA5DD9@OSZP286MB0742.JPNP286.PROD.OUTLOOK.COM>
Accept-Language: zh-CN, en-US
Content-Language: zh-CN
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-ms-exchange-messagesentrepresentingtype: 1
x-tmn: [z+46GJ+exZeCfWPtoBonDf/lzyps9ZFP]
x-ms-publictraffictype: Email
x-ms-traffictypediagnostic: OS3P286MB0740:EE_|OSZP286MB1488:EE_
x-ms-office365-filtering-correlation-id: e27f050e-9b93-4639-b1d4-08db0f26f376
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: H26pLV1VxA4CuEWzFIzTgYvpzT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bzkCKs1ur5AXmjUdaMazoFdxPsbSgyM
TqznR0nvz+wxZGlxsH/98oeM8enPYqGDtJTaeWsCa2TVw
ugtpsWDmccSt8BlVfH2zjs0bLAaByze6pH6A3y92i8+x6
xWf8aF1UkwvmrazpdBNCrb9jf2JySm+lA0y8W5RMT6UX9
EjCZ/gC5oAjIBoivDuS7NGhAdbFiYVNjOctmtqNiYRH/W
7qN4LjG8Y7Fyf9eTICF4K/PgeIqovro4RbUlKC7oGIPya
Aa7f8+MhCM3jatVLeK/rRRmoiMsHRXbOz76lAQafb8csj
vuhspk/ViohvumZ4AOQQmX8calcoOdPA35ztRdQ3GWhp6
jru1FMnt6fhJNsdPssvu4qXU6ijmHlZT2LWMOF5zyJF8b
+pdYBbRXlB0rE7sn3nxWOG91eGrnrz8IM0pnF3aRs+l70
gQl2LFR3dltQq7eEW3SSMVc/qa0a8GfRqlAzk5R9SmUx4
SQ2B6svUEPGYegBO+RChcsGo2tadMXcRbZE/9wgfhOOwK
VvwsrdlHZR84LdNY/7fDMd5OTkriqat+3k3jzBI5+1CYr
pjD4QepFiXHsuEX1zlsCJRvN+FpLRJ7R2Brk6jKzNGBBn
RIusjIv2db0yKhIHmOvIzOFPoeipFufV6Q5ZpSfgwHVMu
79lyA2hekDUKOhXT3gaTelSDj5IzpA24OPGEPxcZRIpYV
qSAm7eivOhYRKpICL6Y8/HGFrS7qB4PRyJMMdbbNiXYp3
6xhAQT112zqrjLlTA3rjMoc1WdfUCss0gAMk4BpM7JyDE
SE1Yii/mEMsJWecOqU9C+UM5zT3ymgveGfPbT80OVXjIS
7R+/Whcrpt7clasFxiGw9MQnyvn5rWNoOh4LROQtmkLrr
JdLL6k+PonZbq3p4ls=
X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-05f45.templateTenant
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: OS3P286MB0740.JPNP286.PROD.OUTLOOK.COM
X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000
X-MS-Exchange-CrossTenant-Network-Message-Id: e27f050e-9b93-4639-b1d4-08db0f26f376
X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Feb 2023 07:33:37.0561 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa
X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000
X-MS-Exchange-Transport-CrossTenantHeadersStamped: OSZP286MB1488
X-Mailman-Approved-At: Wed, 15 Feb 2023 12:16:40 -0500
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <OS3P286MB0740CCCB1D94B91E01BB4B79A5A39@OS3P286MB0740.JPNP286.PROD.OUTLOOK.COM>
X-Mailman-Original-References: <OSZP286MB0742B742ED736B07B5665A9DA5DD9@OSZP286MB0742.JPNP286.PROD.OUTLOOK.COM>
 by: scruel tao - Wed, 15 Feb 2023 07:33 UTC

If we have the following code:
```
parser = argparse.ArgumentParser(description="test")
parser.add_argument('path')
```
Run it without args, will get error message:
```
usage: test.py [-h] path
test.py: error: the following arguments are required: path
```
However, I hope the message can be as the following:
```
usage: test.py [-h] <path>
test.py: error: the following arguments are required: path
```
Or might can consider to provide a way to let user have there own style, like:
```
usage: test.py [-h] path
```
Thanks.

Re: Add angle brackets for required args in argparse

<tt0lpr$s0oc$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21777&group=comp.lang.python#21777

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail
From: nntp.mbo...@spamgourmet.com (Mark Bourne)
Newsgroups: comp.lang.python
Subject: Re: Add angle brackets for required args in argparse
Date: Mon, 20 Feb 2023 20:39:22 +0000
Organization: A noiseless patient Spider
Lines: 72
Message-ID: <tt0lpr$s0oc$1@dont-email.me>
References: <OSZP286MB0742B742ED736B07B5665A9DA5DD9@OSZP286MB0742.JPNP286.PROD.OUTLOOK.COM>
<OS3P286MB0740CCCB1D94B91E01BB4B79A5A39@OS3P286MB0740.JPNP286.PROD.OUTLOOK.COM>
<mailman.1832.1676481401.20444.python-list@python.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 20 Feb 2023 20:39:23 -0000 (UTC)
Injection-Info: reader01.eternal-september.org; posting-host="c2b0e4150a578e0a8832ea36a9cf321b";
logging-data="918284"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18PcwiTMQSjPC6Od0riHwBM"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
SeaMonkey/2.53.15
Cancel-Lock: sha1:TJPphbkvrvIkcZsIRACQZr1syeI=
In-Reply-To: <mailman.1832.1676481401.20444.python-list@python.org>
 by: Mark Bourne - Mon, 20 Feb 2023 20:39 UTC

scruel tao wrote:
> If we have the following code:
> ```
> parser = argparse.ArgumentParser(description="test")
> parser.add_argument('path')
> ```
>
> Run it without args, will get error message:
> ```
> usage: test.py [-h] path
> test.py: error: the following arguments are required: path
> ```
>
> However, I hope the message can be as the following:
> ```
> usage: test.py [-h] <path>
> test.py: error: the following arguments are required: path
> ```

The `metavar` argument to `add_argument` can be used to control how an
argument is represented in the usage text:
```
import argparse
parser = argparse.ArgumentParser(description='test')
parser.add_argument('path', metavar='<path>')
parser.parse_args()
```

Which results in:
```
usage: test.py [-h] <path>
test.py: error: the following arguments are required: <path>
```

> Or might can consider to provide a way to let user have there own style, like:
> ```
> usage: test.py [-h] path
> ```

It's also possible to create a custom help formatter, overriding
appropriate methods to control the formatting. For example:
```
import argparse

class CustomHelpFormatter(argparse.HelpFormatter):
def _get_default_metavar_for_positional(self, action):
default = super()._get_default_metavar_for_positional(action)
return f'<{default}>'

parser = argparse.ArgumentParser(
description='test',
formatter_class=CustomHelpFormatter)
parser.add_argument('path')
parser.parse_args()
```

Which results in:
```
usage: test.py [-h] <path>
test.py: error: the following arguments are required: path
```

That's a bit closer to what you asked for, since the required argument
shown in the error message doesn't include the angle brackets. It also
avoids needing to specify a `metavar` for every positional argument.
However, it is overriding a non-public method of the `HelpFormatter`
class, so might not work across all Python versions if the name or
signature of that method changes (even if it does work with all current
versions, it might break in future).

--
Mark.

Re: Add angle brackets for required args in argparse

<mailman.1931.1677120208.20444.python-list@python.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21845&group=comp.lang.python#21845

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail
From: scru...@hotmail.com (scruel tao)
Newsgroups: comp.lang.python
Subject: Re: Add angle brackets for required args in argparse
Date: Thu, 23 Feb 2023 02:43:23 +0000
Lines: 18
Message-ID: <mailman.1931.1677120208.20444.python-list@python.org>
References: <OSZP286MB0742B742ED736B07B5665A9DA5DD9@OSZP286MB0742.JPNP286.PROD.OUTLOOK.COM>
<OS3P286MB0740CCCB1D94B91E01BB4B79A5A39@OS3P286MB0740.JPNP286.PROD.OUTLOOK.COM>
<mailman.1832.1676481401.20444.python-list@python.org>
<tt0lpr$s0oc$1@dont-email.me>
<OS3P286MB0740568C7894506D10154669A5AB9@OS3P286MB0740.JPNP286.PROD.OUTLOOK.COM>
Mime-Version: 1.0
Content-Type: text/plain; charset="Windows-1252"
Content-Transfer-Encoding: quoted-printable
X-Trace: news.uni-berlin.de 11916OF4Ou819fz+bWwa6w4wxvuc0iJ2ZeM64qKvdp9A==
Return-Path: <scruelt@hotmail.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=hotmail.com header.i=@hotmail.com header.b=T9GFCoLC;
dkim-adsp=pass; dkim-atps=neutral
X-Spam-Status: OK 0.073
X-Spam-Evidence: '*H*': 0.86; '*S*': 0.00; 'argument': 0.04;
'subject:Add': 0.04; 'class,': 0.05; '&gt;&gt;&gt;': 0.07;
'parse': 0.09; 'skip:` 10': 0.09; 'versions,': 0.09; '(even':
0.16; 'specify': 0.16; 'subject:required': 0.16; 'python': 0.16;
'to:addr:python-list': 0.20; 'code': 0.23; 'to:name:python-
list@python.org': 0.24; 'bit': 0.27; '>>>': 0.28; 'asked': 0.29;
'error': 0.29; "doesn't": 0.32; 'mark': 0.32; 'subject:for': 0.33;
'same': 0.34; 'header:In-Reply-To:1': 0.34; 'fine': 0.35; 'url-
ip:13.107/16': 0.38; 'way': 0.38; 'changes': 0.39; 'use': 0.39;
'break': 0.39; 'still': 0.40; 'should': 0.40;
'charset:windows-1252': 0.60; 'provide': 0.60; 'method': 0.61;
'skip:h 10': 0.61; 'format': 0.62; 'your': 0.64; 'required': 0.65;
'now,': 0.67; 'url-ip:104.18/16': 0.67; 'right': 0.68;
'themselves.': 0.69; 'times': 0.69; 'signature': 0.76; 'strategy':
0.84; 'angle': 0.84; 'think,': 0.91; 'stable': 0.93
ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none;
b=JrH9GVO1HwSpDAANhj9svv8eaofZBFTMBrBKa9mk42rl9R1t8Nn4E6nljcjyB9I7p7GKgsXpa0VTddM6tOEMxTKi+PW/YGrVW0y+EjpbJ96dMM/boWEWgKoBJOdsAwj7RcVYkqbOZ4FodfuZdtPEG8CKasfXpfvoiaHp6oSIcD1BcQollhi0vdGOWF7D8GEDjjegySUgwXmtvcKvpT0zm1mSFlcqnJWqc7ewxQYVeCTArtWwSFZxT6cwrW5L8VqMCprOiVC1ZUdmmQeS+jTYgWATfpX8JAh17ZQE0AQVHfOzjf+hf/gxpa+WO0E9NmyYyHwyLWlwtkM/OJM+ZGfFhA==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;
s=arcselector9901;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1;
bh=KLYtSPCf8Y0dAb501TS3HMQ82BKopXCtrGJ3RlolPZ8=;
b=L6t0AvAs4Ne5tapSHFEnVy50GRGCI+ZoL/ts7bSPdrDA6IvKL/aKMHn3N6npBJ4zrlbdpVyekMmL+vHw0DhQoM8WG/mn3CEFh80HHb2RcORQDjYuvK2D4vuZu3zkln2U3B1kfvgwJm3nd43el/1Wm+ma7IBUayd9rvBmPa9HqQiaqG1Fw6PVwSuYEq+NU1I4AylGjq3+o0gdZg/y6TYe3yehC4bOjinTNcQLsTWMakXu6alRi55A7vWrANbJrf563K2E8EnQFmuYH09EPJ1sx5rbLe18p8tc85o2UPeOnYP3D4DsAhFO6kPn1vDlZVP4kPmBK6Dwoq7r9rkBhAP7MQ==
ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none;
dkim=none; arc=none
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hotmail.com;
s=selector1;
h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;
bh=KLYtSPCf8Y0dAb501TS3HMQ82BKopXCtrGJ3RlolPZ8=;
b=T9GFCoLCQmd39Swp0mYe04ZpkZjGYG4o15YG6mYoxb/1cRLT30L6OQ/hfUYzebf16gaf52KhfZI08yPlJsLjmc2qeyVwUkWzV2yh1lnRwQgafJLLZdSHxjZ3+u7QWnxPP8NeIS0B+0MEY3YRefpkOC9wnQSGP1XlxBHoGQGwPTFJV4Ybae/edNEGg/4/AyVClE7xVXPbfBdhZPLxZXpHHL3TonYpHQsIp0XIYgMZR4x/V95IVly1gL9mr6UnzF5t1+nCwng8QJGUbKchZyEuqlDU1w3z8Xuj1d6HPPXJGXUtcKR7a8rdztsT0ZwXzf1FGS2nkuVjCKNwdM2qOF+iiQ==
Thread-Topic: Add angle brackets for required args in argparse
Thread-Index: AQHZP4dtNgofviXt8U+xP9Q6+m5xNq7PoH/ggAkPJ/iAAy7G8w==
In-Reply-To: <tt0lpr$s0oc$1@dont-email.me>
Accept-Language: zh-CN, en-US
Content-Language: zh-CN
X-MS-Has-Attach:
X-MS-TNEF-Correlator:
x-ms-exchange-messagesentrepresentingtype: 1
x-tmn: [hAS+r4ciDbsY2vv+KU9Ww70wCg9MnwZ5]
x-ms-publictraffictype: Email
x-ms-traffictypediagnostic: OS3P286MB0740:EE_|TYCP286MB3129:EE_
x-ms-office365-filtering-correlation-id: 3288a485-72fa-4c4f-63dc-08db1547bb3a
x-microsoft-antispam: BCL:0;
x-microsoft-antispam-message-info: 742zTSD4Nse6+HMBm5V3AJdLmwNfiay3GXm7U+eLXEU2inFbbt5eH7754ew79k11F4qyvTVsbnCve7jHUhWPVgYRdBemY5fXbDOIon2K7Fa/bA7QvLOLSeG2GRFg168zUwewansY49aGd/5xBK1t7EW6xVjcxiTcJJ73b4mWeX1GT7zN4gdkqWWwGGxBSdirNo75c5bjQCSWmvrmqun1IGzYSA5/UMQ+sf1jWKvrFlgXmwfVNxdIL15d8kxqFqavPFeVq+i8hRpGEmu638D9e0M6wqkOp7H5uAsvQeIUMnesx75+MyHz//V2JApRHc4Dp4xX24gmYpuGitBxFji/sedEcALxTYqhk13VqobMp/uxuDS0ufpTwb66Xox30bRAF6t1ml45YfURXKoEGarmY1OMGhqo0JIGDCW2Lq4SeYGeCVTrufaT0gpCAhOUKvVlkaRzQ6fxO/yGg504ZdTWY4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lsKtX3klGiyGkznGAmTx8pn425aolHXcm4WSOuoIRF7g
yG4YnpyaY5+HxcgAEnn2/wI3rJgEBp5JlzpqNFGejmXOjgFjsF2oe9sd
t/zhZoppGuXUQGZC401y+uTJ+SQXUteTCryr20Wp69TxjOkBiPFVmfts
zu22nza1sLftWMg0fHHYOs1EiL82mKRDgwuT/5udnmnGajnPhkKqEyje
GNEgd8/u6OZSzhMwzdXrlxRe2HBcBNbDoWcUmKa7NTwbjARnN3X2Im1h
A2uHjjJkTFgrpBCdX9/zMPGylzwowxAzyzijsrN5ufUMbig8NH0xzdge
Dt729ue6YUip7xNFfmAnaZ3Yp8ni7ouT5J5zAY5dlSwNp/z3XSnsvv7Y
LLXNsCI6brnej4YtYzMlcoGRbAVWZPZclzw/PpLWACTF33Zv4xqs4Rh5
XB7wBtErgYZ+5SNYRurWUIGVZjV3AFQuKcGJvFqF2tTE2ayLFB1gDh0l
JDCXMh+6nDcPmAPuyWoCb0hAHw1/BrCVJw4=
X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-05f45.templateTenant
X-MS-Exchange-CrossTenant-AuthAs: Internal
X-MS-Exchange-CrossTenant-AuthSource: OS3P286MB0740.JPNP286.PROD.OUTLOOK.COM
X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000
X-MS-Exchange-CrossTenant-Network-Message-Id: 3288a485-72fa-4c4f-63dc-08db1547bb3a
X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Feb 2023 02:43:23.0615 (UTC)
X-MS-Exchange-CrossTenant-fromentityheader: Hosted
X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa
X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000
X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYCP286MB3129
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <OS3P286MB0740568C7894506D10154669A5AB9@OS3P286MB0740.JPNP286.PROD.OUTLOOK.COM>
X-Mailman-Original-References: <OSZP286MB0742B742ED736B07B5665A9DA5DD9@OSZP286MB0742.JPNP286.PROD.OUTLOOK.COM>
<OS3P286MB0740CCCB1D94B91E01BB4B79A5A39@OS3P286MB0740.JPNP286.PROD.OUTLOOK.COM>
<mailman.1832.1676481401.20444.python-list@python.org>
<tt0lpr$s0oc$1@dont-email.me>
 by: scruel tao - Thu, 23 Feb 2023 02:43 UTC

Thank you for your workarounds, Mark Bourne.
`metavar` argument should be sufficient for infrequent use scenarios, and I will consider to use the custom help formatter if necessary.

>>> That's a bit closer to what you asked for, since the required argument
>>> shown in the error message doesn't include the angle brackets. It also
>>> avoids needing to specify a `metavar` for every positional argument.
>>> However, it is overriding a non-public method of the `HelpFormatter`
>>> class, so might not work across all Python versions if the name or
>>> signature of that method changes (even if it does work with all current
>>> versions, it might break in future).

Your are right to be concerned, that’s why I still think, might the `argparse` can provide a more stable way which can set such format strategy globally, your workarounds are fine to work now, just I have to write the same code to parse either `metaver` or `formatter` every times I use argparse.
Might can have different argparse subclasses, or make some HelpFormatter builtin, so that users won’t need to write them by themselves.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor