Ellipses operator in optional arguments
See original GitHub issueI cannot seem to get the ...
operator to parse correctly within optional arguments. I am migrating my project from argparse to docopt. The docstring is as follows:
rpcalc, a reverse polish notation calculator Usage: rpcalc [-s N] [-i X...] rpcalc [-e] -i X... rpcalc (-h | --help) rpcalc --version Options: -h --help Show this screen. -s N Limit length of stack to N elements. -i X... Push following elements to stack. -e Limit stack length to amount of elements given with -i. --version Display version.
I get the following cryptic error message from docopt:
$ python3 rpcalc.py -i 1 2 3 Usage: rpcalc [-s N] [-i X...] rpcalc [-e] -i X... rpcalc (-h | --help) rpcalc --version
It looks like [-i X...]
in the first Usage line is what’s causing the issue.
TL;DR Can docopt handle the ellipses operator within [
]
?
Issue Analytics
- State:
- Created 10 years ago
- Reactions:1
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Ellipsis in C++ with Examples
Ellipsis in C++ allows the function to accept an indeterminate number of arguments. It is also known as the variable argument list.
Read more >12.6 — Ellipsis (and why to avoid them)
The ellipsis capture any additional arguments (if there are any). ... fixed parameters represent the number of optional parameters passed.
Read more >How to pythonically have partially-mutually exclusive ...
My proposal is focused on data encapsulation and code readability. a) Pick pair on unambigous measurements to represent ellipse internally
Read more >9.6 A Note on Ellipses | Beginning Computer Science with R
The functions of the previous section contained a mysterious ... argument in their definitions. This is known in R as the ellipsis argument,...
Read more >When Do You Use an Ellipsis in Python?
In this tutorial, you'll learn when Python's Ellipsis constant ... With *args: int , you also allow a variable number of optional arguments, ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Well, argparse allows options to specify multiple arguments via
nargs='*'
andnargs='+'
. Can you elaborate on why you think it is a misfeature? I think it is a very common idiom.Fair enough; thanks for the clarification. Perhaps this could be cleared up in the docs.