Popular recipes by thom neale http://code.activestate.com/recipes/users/4176069/2012-03-01T19:00:04-08:00ActiveState Code RecipesRecursive defaultdict (Python)
2012-03-01T19:00:04-08:00thom nealehttp://code.activestate.com/recipes/users/4176069/http://code.activestate.com/recipes/578057-recursive-defaultdict/
<p style="color: grey">
Python
recipe 578057
by <a href="/recipes/users/4176069/">thom neale</a>
(<a href="/recipes/tags/defaultdict/">defaultdict</a>).
</p>
<p>A defaultdict that yields a defaultdict that yields a defaultdict, etc...</p>
Roman numeral class with overloaded int methods (Python)
2011-04-06T14:52:06-07:00thom nealehttp://code.activestate.com/recipes/users/4176069/http://code.activestate.com/recipes/577640-roman-numeral-class-with-overloaded-int-methods/
<p style="color: grey">
Python
recipe 577640
by <a href="/recipes/users/4176069/">thom neale</a>
(<a href="/recipes/tags/homework/">homework</a>, <a href="/recipes/tags/int/">int</a>, <a href="/recipes/tags/overloading/">overloading</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/roman/">roman</a>).
</p>
<p>This Roman class is a subclass of int and supports the same methods int does, but any special methods that would normally return ints are return a new instance of Roman. You can use instances of this class in math expressions and a Roman instance will be returned, for example. </p>
<p>The class decorator used to achieve this was suggested by Alex Martelli '<a href="http://stackoverflow.com/questions/1242589/subclassing-int-to-attain-a-hex-representation/1243045#1243045">here</a> on stackoverlow.com.</p>
setdict (Python)
2010-11-27T03:00:28-08:00thom nealehttp://code.activestate.com/recipes/users/4176069/http://code.activestate.com/recipes/577471-setdict/
<p style="color: grey">
Python
recipe 577471
by <a href="/recipes/users/4176069/">thom neale</a>
(<a href="/recipes/tags/dict/">dict</a>, <a href="/recipes/tags/dictionary/">dictionary</a>, <a href="/recipes/tags/set/">set</a>).
</p>
<p>Set-like operations for dictionaries</p>