0

I recently found this package (docopt), but i cant seem to get it to work properly. Any help what so ever is appreciated.

The code:

"""docopt_demo.

Usage:
  docopt_demo <name>...
  docopt_demo --version

"""
from docopt import docopt

arguments = docopt(__doc__) #   <---- $0

print("WTF!") #                 <---- $1

The output:

Usage:
  docopt_demo <name>... 
  docopt_demo --version 
[Finished in 0.052s] 

Why?

  1. Why doesn't $1 print?
  2. Why does $0 print?
  3. If $0 is supposed to run last, how do i access the values from $0?
Olian04
  • 6,480
  • 2
  • 27
  • 54

1 Answers1

0

The problem here is that your script is exiting before it gets to the print statement. The script is exiting because you have not provided a valid option. Try python docopt_demo.py --version or python docopt_demo.py Oilan.

Henry Heath
  • 1,072
  • 11
  • 19