Re: Q: Callbacks for (what else) Optional Arguments
Greg Ward <[email protected]> Thu, 26 May 2005 20:44:44 -0400
| Newsgroups | gmane.comp.python.optik.user |
|---|---|
| Message-ID | <[email protected]> |
[sorry for the long delay -- I've just moved and am a little behind on
my email]
On 14 April 2005, Tom Vrankar said:
> So I'm trying to use Python's optparse module to handle a complex set
> of options including a couple with optional arguments. I appreciate the
> confusion surrounding how to handle multiple options in the same token,
> but this isn't something that hasn't been solved before: I'll continue
> to support the convention I've learned. For example:
[...]
> Or I just plain missed something, as the idiom I now think I need looks
> whacked:
>
> parser.add_option("-c", "--callback", type="str", nargs=0,
> action="callback", callback=varargs)
AFAIK you're not missing anything. There is no secret, hidden support
for doing optional option arguments. If I had figured out how to do
this with Optik's existing parser, I would have documented it ages ago.
I strongly suspect the only way to do it is major changes to the parsing
algorithm. I've had a couple of false starts at this over the last year
or two, but never really followed through. I guess it's not something I
want badly enough, alas.
Patches, either to code or docs, are welcome!
Greg
-------------------------------------------------------
This SF.Net email is sponsored by Yahoo.
Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
Search APIs Find out how you can build Yahoo! directly into your own
Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005