Interleaved commands and options with optparse?

Magnus Lie Hetland mlh at furu.idi.ntnu.no
Wed Jan 22 21:33:06 EST 2003


I really love Optik/optparse -- it's a dream to use compared to
getopt, IMO. Hooray!

Now... I'd like to interleave "commands" (i.e. simple arguments) with
my options, as in, e.g., cvs (or distutils, for that matter). For
example:

  python myscript.py --globaloption command --commandoption

I'd like the semantics of the options to depend on where they are
placed, e.g. before or after a command etc. (I might have global and
command-specific switches with the same single-letter abbreviation but
with different meanings -- as in cvs.)

Perhaps this sort of thing goes against the "tao of options" (although
I can't see exactly how/why)? Or perhaps it is possible, and I just
haven't found the right bit of documentation?

-- 
Magnus Lie Hetland
http://hetland.org




More information about the Python-list mailing list