Popular recipes tagged "state_pattern"http://code.activestate.com/recipes/tags/state_pattern/popular/2009-06-15T13:46:39-07:00ActiveState Code Recipes@statemethod (Python) 2009-06-15T13:46:39-07:00Charlie Nolanhttp://code.activestate.com/recipes/users/4170745/http://code.activestate.com/recipes/576808-statemethod/ <p style="color: grey"> Python recipe 576808 by <a href="/recipes/users/4170745/">Charlie Nolan</a> (<a href="/recipes/tags/decorator/">decorator</a>, <a href="/recipes/tags/state_pattern/">state_pattern</a>). </p> <p>Decorator for use with objects following the <a href="http://en.wikipedia.org/wiki/State_pattern">state pattern</a>.</p> Easy State Pattern - support for implementing state machines (Python) 2009-06-15T11:25:17-07:00Rodney Drenthhttp://code.activestate.com/recipes/users/4050661/http://code.activestate.com/recipes/576613-easy-state-pattern-support-for-implementing-state-/ <p style="color: grey"> Python recipe 576613 by <a href="/recipes/users/4050661/">Rodney Drenth</a> (<a href="/recipes/tags/algorithms/">algorithms</a>, <a href="/recipes/tags/decorators/">decorators</a>, <a href="/recipes/tags/metaclasses/">metaclasses</a>, <a href="/recipes/tags/oop/">oop</a>, <a href="/recipes/tags/state_machine/">state_machine</a>, <a href="/recipes/tags/state_pattern/">state_pattern</a>). Revision 3. </p> <p>Provides is a module that gives support for implementing state machines. States are implemented as subclasses, derived from the state machine class. Methods that are state dependant or which cause transitions are declared using decorators. Because states can be subclasses of other states, common behaviour among several states is easily supported. The implementation allows for implementing multiple states or substates within a class.</p> <p>This module best support statem achines implemeting controllers for embedded systems, implementing user interfaces, or in discrete event model simulation. Parsers, which generally have many states and where you would need to define a Transaction method for each different character encountered would be more easily implemented by other means.</p>