Question about optparse/OptionParser callback.

S

Steven W. Orr

I'm new to python and I have a need to do this.

The Cookbook almost takes me there with:

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)

but warns that the "it needs a bit of work: the error message and the flag
that it sets must be generalized". I do need to do my option processing in
an option processor with many options. Is it possible to have a callback
that knows how to access all of the options?

Many thanks. All I need is to be taught how to fish...

--
Time flies like the wind. Fruit flies like a banana. Stranger things have .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top