Popular recipes tagged "meta:loc=118"http://code.activestate.com/recipes/tags/meta:loc=118/2011-08-28T14:34:58-07:00ActiveState Code RecipesHelpMaker: builds help message from comments in the code (Python) 2011-08-28T14:34:58-07:00Yanghttp://code.activestate.com/recipes/users/4178968/http://code.activestate.com/recipes/577860-helpmaker-builds-help-message-from-comments-in-the/ <p style="color: grey"> Python recipe 577860 by <a href="/recipes/users/4178968/">Yang</a> (<a href="/recipes/tags/comments/">comments</a>, <a href="/recipes/tags/help/">help</a>). </p> <p>This tiny module is to make your comments in the source code a bit more useful, to be displayed as help messages. With the HelpMaker, once you finish writing/updating the comments, the help messages are ready. One more reason to work on your comments =)</p> K-means (Python) 2011-06-04T10:58:09-07:00Gabriel Synnaevehttp://code.activestate.com/recipes/users/4178198/http://code.activestate.com/recipes/577734-k-means/ <p style="color: grey"> Python recipe 577734 by <a href="/recipes/users/4178198/">Gabriel Synnaeve</a> (<a href="/recipes/tags/data_mining/">data_mining</a>, <a href="/recipes/tags/machine_learning/">machine_learning</a>). Revision 2. </p> <p>Hard and soft k-means implemented simply in python (with numpy). Quick and dirty, tested and works on large (10k+ observations, 2-10 features) real-world data.</p> Poor Man unit tests (Python) 2011-01-08T18:57:18-08:00Kevin L. Sitzehttp://code.activestate.com/recipes/users/4173535/http://code.activestate.com/recipes/577538-poor-man-unit-tests/ <p style="color: grey"> Python recipe 577538 by <a href="/recipes/users/4173535/">Kevin L. Sitze</a> (<a href="/recipes/tags/assertions/">assertions</a>, <a href="/recipes/tags/testing/">testing</a>, <a href="/recipes/tags/unittests/">unittests</a>). </p> <p>When building unit tests for modules many times using PyUnit feels like overkill. This is a simple implementation for testing single file modules.</p> Render tables for text interface (Python) 2010-04-20T18:02:51-07:00Denis Barmenkovhttp://code.activestate.com/recipes/users/57155/http://code.activestate.com/recipes/577202-render-tables-for-text-interface/ <p style="color: grey"> Python recipe 577202 by <a href="/recipes/users/57155/">Denis Barmenkov</a> (<a href="/recipes/tags/format/">format</a>, <a href="/recipes/tags/table/">table</a>, <a href="/recipes/tags/text/">text</a>). Revision 2. </p> <p>Sometime pprint module is not enough for formatting data for console or log file output. This module provide function which fill the gap.</p> <p><strong>Sample function call:</strong></p> <pre class="prettyprint"><code>nums = [ '1', '2', '3', '4' ] speeds = [ '100', '10000', '1500', '12' ] desc = [ '', 'label 1', 'none', 'very long description' ] lines = format_table( [(nums, ALIGN_RIGHT|PADDING_ALL, 'NUM'), (speeds, ALIGN_RIGHT|PADDING_ALL, 'SPEED'), (desc, ALIGN_LEFT|PADDING_ALL, 'DESC')] ) </code></pre> <p><strong>Output:</strong></p> <pre class="prettyprint"><code>======================================= | NUM | SPEED | DESC | ======================================= | 1 | 100 | | | 2 | 10000 | label 1 | | 3 | 1500 | none | | 4 | 12 | very long description | ======================================= </code></pre> Bible Verse Quiz - timeout.py (Python) 2010-02-12T04:19:59-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/577045-bible-verse-quiz-timeoutpy/ <p style="color: grey"> Python recipe 577045 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/bible/">bible</a>, <a href="/recipes/tags/quiz/">quiz</a>, <a href="/recipes/tags/verse/">verse</a>, <a href="/recipes/tags/_versematch_/">_versematch_</a>). Revision 2. </p> <p>Provide way to add timeout specifications to arbitrary functions.</p> <p>There are many ways to add a timeout to a function, but no solution is both cross-platform and capable of terminating the procedure. This module use the multiprocessing module to solve both of those problems.</p> LD50 and LD90 Calculation (Python) 2009-05-08T01:39:07-07:00donyo Ganchevhttp://code.activestate.com/recipes/users/4167704/http://code.activestate.com/recipes/576743-ld50-and-ld90-calculation/ <p style="color: grey"> Python recipe 576743 by <a href="/recipes/users/4167704/">donyo Ganchev</a> . </p> <p>Calculation of LD50 and LD90 with Statlib</p> Alternative to __del__ through __finalize__ and __finalattrs__ (Python) 2007-05-13T19:13:22-07:00Steven Bethardhttp://code.activestate.com/recipes/users/1985807/http://code.activestate.com/recipes/519635-alternative-to-__del__-through-__finalize__-and-__/ <p style="color: grey"> Python recipe 519635 by <a href="/recipes/users/1985807/">Steven Bethard</a> . Revision 4. </p> <p>This recipe introduces a __finalize__ method along with a __finalattrs__ class attribute which can be used for simple finalization without all the complications that __del__ currently creates.</p> <p>Simply list any instance attributes that need to be available for finalization in the __finalattrs__ class attribute. When the instance is garbage collected, the __finalize__ method will be called with an object exposing just the __finalattrs__ attributes.</p> Simple XML RPC server over HTTPS (Python) 2006-06-07T07:17:34-07:00Laszlo Nagyhttp://code.activestate.com/recipes/users/2914829/http://code.activestate.com/recipes/496786-simple-xml-rpc-server-over-https/ <p style="color: grey"> Python recipe 496786 by <a href="/recipes/users/2914829/">Laszlo Nagy</a> (<a href="/recipes/tags/web/">web</a>). </p> <p>Simple program that demonstrates how to write an XMLRCP server that uses https for transporting XML data.</p> QuackTemplate.Wrapper (Python) 2006-05-22T09:21:16-07:00Costas Malamashttp://code.activestate.com/recipes/users/2897303/http://code.activestate.com/recipes/496730-quacktemplatewrapper/ <p style="color: grey"> Python recipe 496730 by <a href="/recipes/users/2897303/">Costas Malamas</a> (<a href="/recipes/tags/text/">text</a>). </p> <p>QuackTemplate.Wrapper is a template helper class: it takes arbitrary Python objects and uses__gettitem__ so that the wrapped object can be passed into the standard Python string substitution mechanism. It can follow method calls, dict keys and list members (to some extent).</p> Classes for Working with URIs (Python) 2006-02-12T10:24:56-08:00Duncan McGreggorhttp://code.activestate.com/recipes/users/1923213/http://code.activestate.com/recipes/473864-classes-for-working-with-uris/ <p style="color: grey"> Python recipe 473864 by <a href="/recipes/users/1923213/">Duncan McGreggor</a> (<a href="/recipes/tags/web/">web</a>). Revision 3. </p> <p>This is a set of classes I have used for dealing with URL parsing in an easy and convenient manner. It keeps the code clean, etc.</p> programming language popularity from sourceforge.net and freshmeat.net (Python) 2005-06-13T09:37:50-07:00Scott Tsaihttp://code.activestate.com/recipes/users/2482534/http://code.activestate.com/recipes/425529-programming-language-popularity-from-sourceforgene/ <p style="color: grey"> Python recipe 425529 by <a href="/recipes/users/2482534/">Scott Tsai</a> (<a href="/recipes/tags/web/">web</a>). </p> <p>This recipe uses the mechanize module to grab the "number of projects per progamming language" information from two large opensource software release sites. The information is interesting when comparing popularity of programming languages.</p>