Popular recipes tagged "defaultdict"http://code.activestate.com/recipes/tags/defaultdict/2015-07-15T12:37:13-07:00ActiveState Code RecipesHivemind (Python) 2015-07-15T12:37:13-07:00Oscar Byrnehttp://code.activestate.com/recipes/users/4192487/http://code.activestate.com/recipes/579082-hivemind/ <p style="color: grey"> Python recipe 579082 by <a href="/recipes/users/4192487/">Oscar Byrne</a> (<a href="/recipes/tags/borg/">borg</a>, <a href="/recipes/tags/defaultdict/">defaultdict</a>, <a href="/recipes/tags/hash/">hash</a>, <a href="/recipes/tags/hashing/">hashing</a>, <a href="/recipes/tags/hivemind/">hivemind</a>, <a href="/recipes/tags/python/">python</a>, <a href="/recipes/tags/singleton/">singleton</a>, <a href="/recipes/tags/state/">state</a>). </p> <p>Inspired by the ever-popular Borg pattern, objects inheriting from Hivemind share state if initialised with the same arguments</p> Recursive 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> subclass defaultdict to tell default_factory which key is missing (Python) 2009-09-27T12:15:27-07:00Mick Krippendorfhttp://code.activestate.com/recipes/users/4171813/http://code.activestate.com/recipes/576913-subclass-defaultdict-to-tell-default_factory-which/ <p style="color: grey"> Python recipe 576913 by <a href="/recipes/users/4171813/">Mick Krippendorf</a> (<a href="/recipes/tags/defaultdict/">defaultdict</a>). Revision 5. </p> <p>In a little Prolog interpreter I'm writing I needed a simple and concise way to create Var-objects and also store them in a mapping <em>varname</em> -> <em>Var-object</em> representing the scope of the current Prolog rule. Also, anonymous Prolog variables ("_") should not go into the mapping and should be renamed to <em>_&lt;unique-number&gt;</em>. I came up with this:</p>