Issue38438
Created on 2019-10-10 20:24 by bobjalex, last changed 2022-04-11 14:59 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 17106 | merged | brandtbucher, 2019-11-11 06:14 | |
| Messages (11) | |||
|---|---|---|---|
| msg354402 - (view) | Author: Bob Alexander (bobjalex) * | Date: 2019-10-10 20:24 | |
This program:
import argparse
ap = argparse.ArgumentParser()
ap.add_argument("arg", nargs="*")
ap.parse_args()
Gives usage message:
usage: help_complexity.py [-h] [arg [arg ...]]
It's correct, but unnecessarily complex and challenging to the user.
If I were manually writing the usage, arg... would do, or maybe [arg ...] to be consistent with other messages??
|
|||
| msg354410 - (view) | Author: Eric V. Smith (eric.smith) * | Date: 2019-10-10 21:55 | |
I think [arg ...] would make sense. Removing 3.5 and 3.6, since they're in security only mode. Adding 3.9. |
|||
| msg354419 - (view) | Author: Raymond Hettinger (rhettinger) * | Date: 2019-10-11 05:19 | |
Bob, would like to create a PR? |
|||
| msg354450 - (view) | Author: Brandt Bucher (brandtbucher) * | Date: 2019-10-11 13:36 | |
I’m happy to write one. This seems like a pretty straightforward fix. |
|||
| msg354457 - (view) | Author: Raymond Hettinger (rhettinger) * | Date: 2019-10-11 14:18 | |
Bob, as OP you get first dibs on a PR. Brandt, you're next in line :-) |
|||
| msg354467 - (view) | Author: Nick Timkovich (nicktimko) * | Date: 2019-10-11 17:02 | |
The `[arg [arg ...]]` feels a bit more formal to me, and I might prefer it in the example shown where the arg name is fairly short. That said, `man mv` shows something like:
mv [OPTION]... [-T] SOURCE DEST
mv [OPTION]... SOURCE... DIRECTORY
mv [OPTION]... -t DIRECTORY SOURCE...
|
|||
| msg354475 - (view) | Author: Brandt Bucher (brandtbucher) * | Date: 2019-10-11 17:30 | |
For backward compatibility with 2 metavars, the two-name form should still be possible. Just pass metavar=("FOO", "FOO").
|
|||
| msg354476 - (view) | Author: Eric V. Smith (eric.smith) * | Date: 2019-10-11 17:31 | |
I don't think it's any more precise. It just seems verbose and confusing to me, while conveying the same information. `[arg [arg ...]]` to me means "optionally, an arg followed by one or more optional args". While `[arg ...]` to me means "optionally, one or more args". So, I'd vote for the simpler version, especially since we're presumably trying to communicate with people who aren't BNF or regex experts! |
|||
| msg356354 - (view) | Author: Brandt Bucher (brandtbucher) * | Date: 2019-11-11 06:16 | |
I went ahead and opened a PR, since it's been a month. |
|||
| msg356386 - (view) | Author: Raymond Hettinger (rhettinger) * | Date: 2019-11-11 20:47 | |
New changeset a0ed99bca8475cbc82e9202aa354faba2a4620f4 by Raymond Hettinger (Brandt Bucher) in branch 'master': bpo-38438: Simplify argparse "star nargs" usage. (GH-17106) https://github.com/python/cpython/commit/a0ed99bca8475cbc82e9202aa354faba2a4620f4 |
|||
| msg356411 - (view) | Author: Raymond Hettinger (rhettinger) * | Date: 2019-11-12 05:09 | |
Bob, thanks for the suggestion. Brandt, thanks for the PR. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:21 | admin | set | github: 82619 |
| 2019-11-12 05:09:42 | rhettinger | set | status: open -> closed versions: - Python 3.7, Python 3.8 messages: + msg356411 resolution: fixed |
| 2019-11-11 20:47:57 | rhettinger | set | messages: + msg356386 |
| 2019-11-11 06:16:11 | brandtbucher | set | messages: + msg356354 |
| 2019-11-11 06:14:14 | brandtbucher | set | keywords:
+ patch stage: patch review pull_requests: + pull_request16612 |
| 2019-11-04 10:56:00 | callumquick | set | nosy:
+ callumquick |
| 2019-10-24 20:28:19 | paul.j3 | set | nosy:
+ paul.j3 |
| 2019-10-11 17:31:45 | eric.smith | set | messages: + msg354476 |
| 2019-10-11 17:30:37 | brandtbucher | set | messages: + msg354475 |
| 2019-10-11 17:02:29 | nicktimko | set | nosy:
+ nicktimko messages: + msg354467 |
| 2019-10-11 14:18:33 | rhettinger | set | messages: + msg354457 |
| 2019-10-11 13:36:50 | brandtbucher | set | messages: + msg354450 |
| 2019-10-11 05:19:43 | rhettinger | set | assignee: rhettinger messages: + msg354419 |
| 2019-10-11 02:02:12 | xtreak | set | nosy:
+ rhettinger |
| 2019-10-11 00:06:40 | brandtbucher | set | nosy:
+ brandtbucher |
| 2019-10-10 21:55:33 | eric.smith | set | nosy:
+ eric.smith messages:
+ msg354410 |
| 2019-10-10 20:24:39 | bobjalex | create | |