Callbacks are functions called when an optparse.OptionParser() object
has a callback option defined (don't know how to say this less obvious
sounding...) (they are documented in
http://docs.python.org/lib/optparse-option-callbacks.html)

Example (based on an example in the documentation):

this script:
-#!/usr/bin/env python
-import optparse
-def record_foo_seen(option, opt_str, value, parser):
-    print 'saw foo'
-
-parser = optparse.OptionParser()
-parser.add_option("--foo", action="callback",
callback=record_foo_seen)
-(options, args) = parser.parse_args()
-
-print options, args

prints when executed with or without argument:
[EMAIL PROTECTED]:~$ ./test2.py --foo
saw foo
{} []
[EMAIL PROTECTED]:~$ ./test2.py
{} []
[EMAIL PROTECTED]:~$

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to