Popular recipes by Michael Kent http://code.activestate.com/recipes/users/1184676/2010-12-21T04:38:48-08:00ActiveState Code RecipesA powerful yet simple switch-like dispatch system for Python (Python)
2010-12-21T04:38:48-08:00Michael Kenthttp://code.activestate.com/recipes/users/1184676/http://code.activestate.com/recipes/577507-a-powerful-yet-simple-switch-like-dispatch-system-/
<p style="color: grey">
Python
recipe 577507
by <a href="/recipes/users/1184676/">Michael Kent</a>
(<a href="/recipes/tags/dispatcher/">dispatcher</a>, <a href="/recipes/tags/switch/">switch</a>).
Revision 2.
</p>
<p>This module provides a powerful 'switch'-like dispatcher system, using decorators to give a syntax somewhat like that of the switch statement in C. Values for switch cases can be anything comparable via '==', a string for use on the left-hand side of the 'in' operator, or a regular expression.
Iterables of these types can also be used.</p>
A File-Like Object to True File Object Adapter (Python)
2003-05-28T12:14:05-07:00Michael Kenthttp://code.activestate.com/recipes/users/1184676/http://code.activestate.com/recipes/202612-a-file-like-object-to-true-file-object-adapter/
<p style="color: grey">
Python
recipe 202612
by <a href="/recipes/users/1184676/">Michael Kent</a>
(<a href="/recipes/tags/files/">files</a>).
</p>
<p>Sometimes you have a file-like object (such as what urllib.urlopen() returns), but you need to pass it to a function/method that insists on receiving a true file object (what the file or open built-in functions give you). What you need is a adapter to turn your file-like object into a true file object.</p>