CVS style argument parsing?

Jeff Epler jepler at unpythonic.net
Tue Jul 20 20:21:19 EDT 2004


Don't use OptionGroups for each command.  Instead, you'll have the
OptionParser for the "main" arguments, and the option parser for each
command.

By using parser.disable_interspersed_args() you can make the parsing of
"-a b -c".split() handle "-a" and return "b -c".split() as the
positional args.  Then, depending on what b is, send -c to a separate
parser instance.

I don't see where disable_interspersed_args() is documented, but it's
right there in optparse.py

Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20040720/04d63899/attachment.sig>


More information about the Python-list mailing list