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.

Repeating positional arguments followed by a single positional argument

See original GitHub issue

It seems that Docopt is currently not able to parse repeated positional arguments (specified by ellipsis) followed by a last single-valued positional argument. I.e. something like this:

#!/usr/bin/env python

__doc__ = """
Usage: mycopy <src>... <dest>
"""
from docopt import docopt

options = docopt(__doc__)

I’m not sure whether it’s possible to do it without making the code too complex, but it would be great if Docopt was able to parse commands like this.

Issue Analytics

  • State:open
  • Created 9 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
naught101commented, Sep 18, 2015

This also fails:

Usage:
  naval_fate move <name>... [options] <x> <y>
...


$ ./naval_fate.py move a --drifting 2 3  
Usage:
  naval_fate move <name>... [options] <x> <y>
  naval_fate -h | --help
  naval_fate --version

It might be easier to figure out why if we had #291

0reactions
ajmazuriecommented, Feb 28, 2017

Hi! I was wondering if there was some activities related to this issue. I could get it to work with argparse, but it would be a shame to move away from docopt.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Positional-Only Arguments - Real Python
In this lesson, you'll learn about how to add positional-only arguments to your functions in Python 3.8. The built-in function float() can be...
Read more >
Function Parameters and Arguments in Python
Python prioritises the mapping of positional arguments to their parameter names ... repeated >>> foo(a=1, 2, 3) SyntaxError: positional argument follows ...
Read more >
Positional and Keyword Arguments
Python functions can contain two types of arguments: positional arguments and keyword arguments. Positional arguments must be included in the correct order.
Read more >
positional argument follows keyword argument - Stack Overflow
The problem lies in that you appear to have copy/pasted the parameter list, and left some of the default values in place, which...
Read more >
Understanding *args and *kwargs arguments in Python
Although we have defined only one parameter in the greet() function, the * operator takes the input as a positional argument and is...
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