If you want to re-use this callback for several similar options (set a
flag, but blow up if "-b" has already been seen), it needs a bit of
work: the error message and the flag that it sets must be
generalized.
def check_order(option, opt_str, value, parser):
if parser.values.b:
raise OptionValueError("can't use %s after -b" % opt_str)
setattr(parser.values, option.dest, 1)
[...]
parser.add_option("-a", action="/api/v1/web-embed/proxy?proxyUrl=https%3A%2F%2Fdocs.python.org%2F2.4%2Flib%2Fcallback&mode=full", callback=check_order, dest='a')
parser.add_option("-b", action="/api/v1/web-embed/proxy?proxyUrl=https%3A%2F%2Fdocs.python.org%2F2.4%2Flib%2Fstore_true&mode=full", dest="b")
parser.add_option("-c", action="/api/v1/web-embed/proxy?proxyUrl=https%3A%2F%2Fdocs.python.org%2F2.4%2Flib%2Fcallback&mode=full", callback=check_order, dest='c')
See About this document... for information on suggesting changes.