* Bob ([EMAIL PROTECTED]) wrote: > I'd like to setup command line switches that are dependent on other > switches, similar to what rpm does listed below. From the grammar below > we see that the "query-options" are dependent on the query switch, > {-q|--query}. Can "optparse" do this or do I have to code my own > "thing"? Thanks.
After you pull your options and arguments from optparse, just check for them, eg: parser = optparse.OptionParser() ... (options, args) = parser.parse_args() if (option.q and not option.p): parser.error("you must use p to use q") The meaning of -b doesn't change when it follows -a, but if you want that, it is doable by extending optparse. There is even an example in the very good "extending optik"[1] documentation available off the sf.net site: http://optik.sourceforge.net/ regards, mike [1]: optparse is also known as optik -- http://mail.python.org/mailman/listinfo/python-list