Popular recipes by yaipa haa http://code.activestate.com/recipes/users/519352/2003-02-16T14:25:05-08:00ActiveState Code RecipesUsing a Dictionary in place of a 'switch' statement (Python)
2003-02-16T14:25:05-08:00yaipa haahttp://code.activestate.com/recipes/users/519352/http://code.activestate.com/recipes/181064-using-a-dictionary-in-place-of-a-switch-statement/
<p style="color: grey">
Python
recipe 181064
by <a href="/recipes/users/519352/">yaipa haa</a>
(<a href="/recipes/tags/algorithms/">algorithms</a>).
</p>
<p>Description: Rock, Scissors, Paper Game.
Shows a clean way of implementing a 'switch'
statement in Python via a dictionary container.
The dictionary is made up of known 'named states' that
are tested in sequence for their current 'state'.</p>