6.21.4.4 Callback example 1: trivial callback

Python 2.2

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.

See About this document... for information on suggesting changes.