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.

Default value for argument gets assigned to option

See original GitHub issue
"""
Usage:
    bug.py [--opt num] [ARG]

Options:
    --opt num   An option with a value

Arguments:
    ARG         An arg with a default [default: A]
"""

from docopt import docopt
arguments = docopt(__doc__)
print arguments

I expect this to show:

{'--opt': None, 'ARG': 'A'}

What actually happens:

{'--opt': 'A', 'ARG': None}

I’ll take a look into a fix tomorrow if I can.

Issue Analytics

  • State:open
  • Created 11 years ago
  • Comments:15 (11 by maintainers)

github_iconTop GitHub Comments

5reactions
bear24rwcommented, Oct 11, 2014

Hey, what’s the status on this? I would really like to be able to set a default for an optional positional argument.

0reactions
DamienAllonsiuscommented, Oct 18, 2019

Same question as @bear24rw, anybody on the topic nowadays ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Default parameters - JavaScript - MDN Web Docs
Default function parameters allow named parameters to be initialized with default values if no value or undefined is passed.
Read more >
Default arguments in Python - GeeksforGeeks
The default value is assigned by using the assignment(=) operator of the form keywordname=value. Let's understand this through a function ...
Read more >
Setting default value for TypeScript object passed as argument
The trick is to first put in brackets what keys you want to pick from the argument object, with key=value for any defaults....
Read more >
The Beginner's Guide to JavaScript Default Parameters
In the first function call, we didn't pass any argument into the say() function, therefore message parameter took the default value 'Hi' ....
Read more >
Default arguments - cppreference.com
A redeclaration cannot introduce a default for an argument for which a default is already visible (even if the value is the same)....
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