Popular recipes by nosklo http://code.activestate.com/recipes/users/4166478/2011-11-23T02:27:51-08:00ActiveState Code RecipesActiveState recipe importer (Python) 2011-11-23T02:27:51-08:00nosklohttp://code.activestate.com/recipes/users/4166478/http://code.activestate.com/recipes/577958-activestate-recipe-importer/ <p style="color: grey"> Python recipe 577958 by <a href="/recipes/users/4166478/">nosklo</a> (<a href="/recipes/tags/activestate/">activestate</a>, <a href="/recipes/tags/code/">code</a>, <a href="/recipes/tags/import/">import</a>, <a href="/recipes/tags/library/">library</a>). </p> <p>Finally! This code allows you to import any activestate recipe right into your code!</p> <p>Example:</p> <pre class="prettyprint"><code>&gt;&gt;&gt; from activestate.recipe194373 import mreplace &gt;&gt;&gt; print mreplace('ectave steta racipas rock!', ('a', 'e'), ('e', 'a')) active state recipes rock! </code></pre> <p>Save this as <strong>activestate.py</strong></p> User List Subclass (Python) 2008-08-18T09:26:07-07:00nosklohttp://code.activestate.com/recipes/users/4166478/http://code.activestate.com/recipes/576428-user-list-subclass/ <p style="color: grey"> Python recipe 576428 by <a href="/recipes/users/4166478/">nosklo</a> (<a href="/recipes/tags/list/">list</a>, <a href="/recipes/tags/slices/">slices</a>, <a href="/recipes/tags/subclass/">subclass</a>, <a href="/recipes/tags/__getitem__/">__getitem__</a>). Revision 2. </p> <p>As subclassing list has a problem when using __getitem__, __delitem__ and __setitem__ methods with slices (they don't get called because parent implements __getslice__, __delslice__ and __setslice__ respectively), I've coded this UserList class that is a subclass of list, but overwrites these methods. By subclassing this class, you can overwrite __getitem__ and it will be called correctly for slices.</p> Dummy object (Python) 2008-09-06T03:43:13-07:00nosklohttp://code.activestate.com/recipes/users/4166478/http://code.activestate.com/recipes/576447-dummy-object/ <p style="color: grey"> Python recipe 576447 by <a href="/recipes/users/4166478/">nosklo</a> (<a href="/recipes/tags/debug/">debug</a>, <a href="/recipes/tags/dummy/">dummy</a>, <a href="/recipes/tags/generic/">generic</a>, <a href="/recipes/tags/stupid/">stupid</a>, <a href="/recipes/tags/useless/">useless</a>). Revision 7. </p> <p>Have you wished for a completely Dummy object, one that you can do whatever you want to it? One you can return and all expressions will work? </p> <p>No???</p> <p>Hmm.. ok. But here it is anyway.</p> Class to calculate increment of variables based on time (units per seconds) (Python) 2008-08-18T16:29:08-07:00nosklohttp://code.activestate.com/recipes/users/4166478/http://code.activestate.com/recipes/576424-class-to-calculate-increment-of-variables-based-on/ <p style="color: grey"> Python recipe 576424 by <a href="/recipes/users/4166478/">nosklo</a> (<a href="/recipes/tags/increment/">increment</a>, <a href="/recipes/tags/linear/">linear</a>, <a href="/recipes/tags/number/">number</a>, <a href="/recipes/tags/time/">time</a>, <a href="/recipes/tags/units_per_second/">units_per_second</a>, <a href="/recipes/tags/variables/">variables</a>). Revision 3. </p> <p>A simple calculation of small increments to be applied to a variable, given the variable time that has passed since last update, to make a linear increase over time (in units per second).</p> get index of element in list using identity (Python) 2008-08-16T19:41:37-07:00nosklohttp://code.activestate.com/recipes/users/4166478/http://code.activestate.com/recipes/576426-get-index-of-element-in-list-using-identity/ <p style="color: grey"> Python recipe 576426 by <a href="/recipes/users/4166478/">nosklo</a> (<a href="/recipes/tags/compare/">compare</a>, <a href="/recipes/tags/comparision/">comparision</a>, <a href="/recipes/tags/find/">find</a>, <a href="/recipes/tags/identity/">identity</a>, <a href="/recipes/tags/index/">index</a>, <a href="/recipes/tags/is/">is</a>, <a href="/recipes/tags/same_object/">same_object</a>, <a href="/recipes/tags/search/">search</a>). Revision 2. </p> <p>my_list.index(element) returns the index of the element using common comparision (as in == or __eq__() or __cmp__()). If you need to find an element on the list using identity comparing (is) then this function can do it for you</p>