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.

Allow to strip dashes from options in result dictionary

See original GitHub issue

From the project README:

The return value is a simple dictionary with options, arguments and commands as keys, spelled exactly like in your help message.

options['--file'] looks too odd though. That would be great if a user could invoke docopt with additional named parameter:

options = docopt(__doc__, strip_dashes=True)

So that result dictionary has no leading dashes, which is equivalent to:

def strip_dashes(options):
    return {k.lstrip('-'): v for k, v in options.items()}

options = strip_dashes(docopt(__doc__))

Will you accept pull request for this feature?

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
InfernoZeuscommented, May 23, 2017

Had the same issue. I’m using this one liner: args = {arg.lstrip('-') : value for arg, value in docopt(__doc__).items()}

Coming back to post it here, I realised @pavel-paulau has basically the same thing in his original post.

0reactions
keleshevcommented, Oct 9, 2014

@dmwelch let me know if docopt-dispatch solves your problem. If it gets popular I will integrate it into docopt.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Removing dashes from strings in Python - Stack Overflow
I'm trying to write code that will remove dashes from a string if it's in the middle of a word and not between...
Read more >
Format hyphens, dashes, and quotation marks in Pages on Mac
Turn smart dashes on or off · Choose Pages > Settings (from the Pages menu at the top of your screen). · Click...
Read more >
python - How do I remove hyphen from field column
Use the built-in str.replace method accessible on all string objects. Make sure Python is checked in the Parser at the top.
Read more >
Settings - Pleco for Android
Enable Cantonese - Display Cantonese text in entries from dictionaries that include Cantonese pronunciations; if any one of the dictionaries with a definition ......
Read more >
dash(1) - Linux manual page - man7.org
This option has no effect when set after the shell has already started running (i.e. with set). -V vi Enable the built-in vi(1)...
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