On 09/10/2013 01:50, Alex Kleider wrote:

A recent post recommended the docopt module so I've incorporated it into
the code I'm using to learn SQLite. It's not behaving as I expected.
Here's a snippet of code:

#!/usr/bin/env python
# -*- coding : utf -8 -*-
# file: 'test'
"""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]
"""


You have no definitions for new_data, text_entry, FILE and show_data, and the use of the square brackets around them looks wrong. Here's a real life example from my code.

"""Usage: cashflow.py [-t] ACCOUNTS TRANSFERS ENDDATE (report|plot)

Arguments:
  ACCOUNTS      mandatory file containing accounts data
  TRANSFERS     mandatory file containing transfer data
  ENDDATE       mandatory end date for the report or plot

Options:
  -h --help
  -t       show total of accounts

"""

If you haven't already looked at them there are lots of extremely useful examples here https://github.com/docopt/docopt/tree/master/examples.

--
Roses are red,
Violets are blue,
Most poems rhyme,
But this one doesn't.

Mark Lawrence

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to