question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Ellipses operator in optional arguments

See original GitHub issue

I 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:open
  • Created 10 years ago
  • Reactions:1
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
zcrislercommented, Jan 25, 2015

Well, argparse allows options to specify multiple arguments via nargs='*' and nargs='+'. Can you elaborate on why you think it is a misfeature? I think it is a very common idiom.

1reaction
qguvcommented, Jan 10, 2014

Fair enough; thanks for the clarification. Perhaps this could be cleared up in the docs.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found