6.21.4.4 Callback example 1: trivial callback

Here's an example of a callback option that takes no arguments, and simply records that the option was seen:

def record_foo_seen(option, opt_str, value, parser):
 parser.saw_foo = True
parser.add_option("--foo", action="callback", callback=record_foo_seen)

Of course, you could do that with the store_true action.


Python Library Reference
Previous: Up: 6.21.4 Option Callbacks Next:

Release 2.4.4, documentation updated on 18 October 2006.
See About this document... for information on suggesting changes.

AltStyle によって変換されたページ (->オリジナル) /