Popular recipes by Steven Cummings http://code.activestate.com/recipes/users/2310364/2008-07-31T09:32:27-07:00ActiveState Code RecipesGeneral dispatching mechanism for C#-style events (Python)
2005-07-03T17:34:34-07:00Steven Cummingshttp://code.activestate.com/recipes/users/2310364/http://code.activestate.com/recipes/435885-general-dispatching-mechanism-for-c-style-events/
<p style="color: grey">
Python
recipe 435885
by <a href="/recipes/users/2310364/">Steven Cummings</a>
(<a href="/recipes/tags/oop/">oop</a>).
</p>
<p>This is an dynamic dispatching approach inspired by C#-style events. The approach allows for the dispatch of an event to a series of chained methods through the use of a Dispatcher. The Dispatcher can be defined either as part of a class or merely as a variable in some code. When the Dispatcher is invoked the methods that are chained to it (i.e. handlers) are invoked. The dispatch can be either blocking or non-blocking, and is non-blocking by default.</p>
Ensuring a name definition in a module namespace (Python)
2008-07-31T09:32:27-07:00Steven Cummingshttp://code.activestate.com/recipes/users/2310364/http://code.activestate.com/recipes/172431-ensuring-a-name-definition-in-a-module-namespace/
<p style="color: grey">
Python
recipe 172431
by <a href="/recipes/users/2310364/">Steven Cummings</a>
(<a href="/recipes/tags/programs/">programs</a>).
Revision 2.
</p>
<p>Ensure that a name exists in a target namespace. If it does not, make it available in the target namespace using the given definition. The target should be a namespace dictionary (presumably for a module, see the discussion below otherwise). The default target is __builtins__ (specificially, __builtins__.__dict__).</p>