Popular recipes by Dmitry Vasiliev http://code.activestate.com/recipes/users/1571302/2007-08-09T04:52:45-07:00ActiveState Code RecipesUnicode class which adds proper XML declaration on encoding (Python) 2007-08-09T04:52:45-07:00Dmitry Vasilievhttp://code.activestate.com/recipes/users/1571302/http://code.activestate.com/recipes/526626-unicode-class-which-adds-proper-xml-declaration-on/ <p style="color: grey"> Python recipe 526626 by <a href="/recipes/users/1571302/">Dmitry Vasiliev</a> (<a href="/recipes/tags/shortcuts/">shortcuts</a>). </p> <p>Sometimes you want to pass XML document as unicode object which later should be encoded for output. Unfortunately very often you don't know the output encoding and can't set XML declaration properly. UnicodeXML adds XML declaration right on encoding operation.</p> PEP 367 like super (Python) 2007-05-16T09:57:37-07:00Dmitry Vasilievhttp://code.activestate.com/recipes/users/1571302/http://code.activestate.com/recipes/519645-pep-367-like-super/ <p style="color: grey"> Python recipe 519645 by <a href="/recipes/users/1571302/">Dmitry Vasiliev</a> (<a href="/recipes/tags/oop/">oop</a>). </p> <p>The code based on <a href="http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/286195" rel="nofollow">http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/286195</a> but interface is PEP 367 like so you can write just super.base_method() inside a method. See doctests for examples.</p> Decorator to run decorated function not often than defined time interval (Python) 2007-02-22T10:19:59-08:00Dmitry Vasilievhttp://code.activestate.com/recipes/users/1571302/http://code.activestate.com/recipes/502247-decorator-to-run-decorated-function-not-often-than/ <p style="color: grey"> Python recipe 502247 by <a href="/recipes/users/1571302/">Dmitry Vasiliev</a> (<a href="/recipes/tags/shortcuts/">shortcuts</a>). Revision 2. </p> <p>Sometimes it's desirable to run a function not often than some time interval. The timeguard decorator below lets do exactly that. See the doctest for details.</p> Storage for store information about prefixes (Python) 2004-11-15T00:51:38-08:00Dmitry Vasilievhttp://code.activestate.com/recipes/users/1571302/http://code.activestate.com/recipes/335555-storage-for-store-information-about-prefixes/ <p style="color: grey"> Python recipe 335555 by <a href="/recipes/users/1571302/">Dmitry Vasiliev</a> (<a href="/recipes/tags/algorithms/">algorithms</a>). </p> <p>Storage for store information about domains determined by key prefixes. See the docsting for details.</p> Generic cacheable value objects superclass (Python) 2004-08-31T01:08:19-07:00Dmitry Vasilievhttp://code.activestate.com/recipes/users/1571302/http://code.activestate.com/recipes/302699-generic-cacheable-value-objects-superclass/ <p style="color: grey"> Python recipe 302699 by <a href="/recipes/users/1571302/">Dmitry Vasiliev</a> (<a href="/recipes/tags/oop/">oop</a>). </p> <p>Superclass for cache value objects by its constructor arguments (see the Date class for example).</p> Generator for splitting a string on parts of equal size (Python) 2004-08-26T03:05:46-07:00Dmitry Vasilievhttp://code.activestate.com/recipes/users/1571302/http://code.activestate.com/recipes/302069-generator-for-splitting-a-string-on-parts-of-equal/ <p style="color: grey"> Python recipe 302069 by <a href="/recipes/users/1571302/">Dmitry Vasiliev</a> (<a href="/recipes/tags/shortcuts/">shortcuts</a>). </p> <p>Example: &lt;pre&gt;</p> <pre class="prettyprint"><code>&gt;&gt;&gt; list(splitIterator("102030405", 2)) ['10', '20', '30', '40', '5'] &lt;/pre&gt; </code></pre> Decorator for appending author info to the function docstring (Python 2.4) (Python) 2004-08-26T01:17:58-07:00Dmitry Vasilievhttp://code.activestate.com/recipes/users/1571302/http://code.activestate.com/recipes/302036-decorator-for-appending-author-info-to-the-functio/ <p style="color: grey"> Python recipe 302036 by <a href="/recipes/users/1571302/">Dmitry Vasiliev</a> (<a href="/recipes/tags/shortcuts/">shortcuts</a>). </p> <p>Some examples:</p> <p>&lt;pre&gt;</p> <pre class="prettyprint"><code>&gt;&gt;&gt; @author("John") ... @author("Paul") ... def test(): ... "Test function" ... &gt;&gt;&gt; help(test) Help on function test in module __main__: </code></pre> <p>test() Author: John Author: Paul Test function &lt;/pre&gt;</p> Function for print numbers by parts (Python) 2004-08-27T13:39:32-07:00Dmitry Vasilievhttp://code.activestate.com/recipes/users/1571302/http://code.activestate.com/recipes/302035-function-for-print-numbers-by-parts/ <p style="color: grey"> Python recipe 302035 by <a href="/recipes/users/1571302/">Dmitry Vasiliev</a> (<a href="/recipes/tags/shortcuts/">shortcuts</a>). Revision 3. </p> <p>Some examples:</p> <pre class="prettyprint"><code>&gt;&gt;&gt; nprint(9876543210) '9 876 543 210' &gt;&gt;&gt; nprint(987654321, period=1, delimiter=",") '9,8,7,6,5,4,3,2,1,0' </code></pre> Rating class with mapping interface (Python) 2004-01-14T09:10:42-08:00Dmitry Vasilievhttp://code.activestate.com/recipes/users/1571302/http://code.activestate.com/recipes/265879-rating-class-with-mapping-interface/ <p style="color: grey"> Python recipe 265879 by <a href="/recipes/users/1571302/">Dmitry Vasiliev</a> (<a href="/recipes/tags/algorithms/">algorithms</a>). Revision 2. </p> <p>Rating with items sorted by value and accessed by key or rating index.</p>