[issue45110] argparse repeats itself when formatting help metavars

2021-09-11 Thread Lewis Gaul
Lewis Gaul added the comment: Big +1 from me for at least supporting a way to get the more concise output. I've never understood the verbosity of python's argparse where the metavar is repeated. -- nosy: +LewisGaul ___ Python tracker

[issue45110] argparse repeats itself when formatting help metavars

2021-09-06 Thread Forest
Forest added the comment: >Subclassing a help formatter is preferred because it minimizes the chance of >hurting existing users. Fair enough. Whatever the approach, I hope argparse can be made to support this through a simple, documented interface. I had to grovel through standard library

[issue45110] argparse repeats itself when formatting help metavars

2021-09-06 Thread paul j3
paul j3 added the comment: The idea of combining help features by defining a subclass that inherits from other subclasses was endorsed by the original developer (we could dig up an old bug/issue to prove that). The provided subclasses all tweak a "private" method, often one that's buried

[issue45110] argparse repeats itself when formatting help metavars

2021-09-06 Thread Forest
Forest added the comment: To be clear, I wrote those examples to be non-invasive, not patch proposals. A cleaner approach would be possible if patching argparse is an option. (I believe the patch in #42980 proposes such an approach.) -- ___ Python

[issue45110] argparse repeats itself when formatting help metavars

2021-09-06 Thread Forest
Forest added the comment: Here's another working example, allowing alternate separator strings (as requested in #33389) via subclassing: class OneMetavarHelpFormatter(argparse.HelpFormatter): """A formatter that avoids repeating action metavars. """ OPTION_SEPARATOR = ', '

[issue45110] argparse repeats itself when formatting help metavars

2021-09-05 Thread Forest
Forest added the comment: On Mon, 06 Sep 2021 04:58:38 +, paul j3 wrote: >This repeat has been a part of argparse from the beginning, so I can't >see changing the default behavior. Yes, I guessed as much, which is why I first suggested making it optional. >But we could add a

[issue45110] argparse repeats itself when formatting help metavars

2021-09-05 Thread paul j3
paul j3 added the comment: https://bugs.python.org/issue42980 argparse: GNU-style help formatter https://bugs.python.org/issue33389 argparse redundant help string https://bugs.python.org/issue29626 Issue with spacing in argparse module while using help https://bugs.python.org/issue27303

[issue45110] argparse repeats itself when formatting help metavars

2021-09-05 Thread paul j3
paul j3 added the comment: This is has been requested various times on StackOverflow, and possibly here (I'd have to do a search). The closest thing to making a compact action_invocation is to set the metavar to '', and even thing we get a space, eg. -f , --foo Help text This

[issue45110] argparse repeats itself when formatting help metavars

2021-09-05 Thread Forest
Forest added the comment: By the way, I would be happy to submit a patch, either to remove the repeat text or to make it optional via an easily overridden class attribute. -- ___ Python tracker

[issue45110] argparse repeats itself when formatting help metavars

2021-09-05 Thread Forest
Forest added the comment: On Mon, 06 Sep 2021 03:11:16 +, Raymond Hettinger wrote: >The repetition helps improve understanding because not everyone would assume >that a METAVAR shown once would automatically also apply to its long form. I'm struggling to think of a real-world example

[issue45110] argparse repeats itself when formatting help metavars

2021-09-05 Thread Jeremy Kloth
Jeremy Kloth added the comment: Except that the output in question is not for manpages but for the command-line. The analogous would be for `grep --help` (again an excerpt): Context control: -B, --before-context=NUM print NUM lines of leading context -A, --after-context=NUM print NUM

[issue45110] argparse repeats itself when formatting help metavars

2021-09-05 Thread Raymond Hettinger
Raymond Hettinger added the comment: I don't agree this should be changed. The repetition helps improve understanding because not everyone would assume that a METAVAR shown once would automatically also apply to its long form. Also, showing the METAVAR more than one is a norm. For

[issue45110] argparse repeats itself when formatting help metavars

2021-09-05 Thread Karthikeyan Singaravelan
Change by Karthikeyan Singaravelan : -- nosy: +paul.j3, rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list

[issue45110] argparse repeats itself when formatting help metavars

2021-09-05 Thread Forest
New submission from Forest : When argparse actions have multiple option strings and at least one argument, the default formatter presents them like this: -t ARGUMENT, --task ARGUMENT Perform a task with the given argument. -p STRING, --print STRING