[Tutor] docopt module: defaults appear to be ignored

Alex Kleider akleider at sonic.net
Wed Oct 9 05:35:13 CEST 2013


On 2013-10-08 18:02, Steven D'Aprano wrote:

> Since docopt is not a standard part of Python, nor part of the language
> itself, you may not find anyone here who knows it well enough to solve
> the problem. Also keep in mind that docopt is still a fairly young
> package and may still contain bugs. If we can't help, you should try a
> dedicated docopt mailing list, if any, or try contacting the developer.

Fair enough.
I would submit however that it does seem to be an ideal solution to the 
challenge of command line parsing.

> 
> I haven't actually used docopt, but I'm willing to try to help...
Much appreciated.

> 
>> """Usage: test [new_data | text_entry FILE | show_data ] [-hdv]
>> [--db=DATABASE] [--tb=TABLE]
>> 
>> -h --help       show this
>> -d --debug      show debugging statements
>> -v --verbose    shows table when not absolutely necessary.
>> --db DATABASE   specify database file to use [default: ./uwomeds68.db]
>> --tb TABLE      specify table to use [default: matesTb]
> 
> The defaults for --db and --tb aren't valid Python objects. Perhaps you
> need to specify them as strings?

The docopt module converts these into strings if/when they appear in the 
command line arguments.
According to the documentation these items are not quoted (which is what 
I assume you are suggesting.) I did try to quote them but it made no 
difference.
Thanks for taking an interest.
You are correct that only someone who has used it would likely be in a 
position to offer advice.
I would never have heard about it if it wasn't for this list.

ak


More information about the Tutor mailing list