append_const (Was: Python 2.5 update)
"Martin Blais" <[email protected]> Sat, 1 Apr 2006 02:57:30 -0500
| Newsgroups | gmane.comp.python.optik.user |
|---|---|
| Message-ID | <[email protected]> |
By the way, for those using up to Python-2.4 (Optik 1.5a2), here is a
simple trick to implement the append_const action with a callback:
def append_const_cb( const ):
"Create callback to implement an append_const action via a callback=
."
def cb( option, opt_str, value, parser ):
getattr(parser.values, option.dest).append(const)
return cb
parser.add_option(...,
action=3D'callback', callback=3Dappend_const_cb(YOUR_CONSTANT),
...)
parser.add_option(...,
action=3D'callback', callback=3Dappend_const_cb(OTHER_CONSTANT),
...)
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642