# handle an event, return a result (or None) def function1(label, count): return "%s number %i..." % (label, count) def function2(label, count): return label * count # register handlers, trigger events import cregister cregister.setHandler(function1) for i in range(3): cregister.triggerEvent() # simulate events caught by C cregister.setHandler(function2) for i in range(3): cregister.triggerEvent() # routes events to function2