Popular recipes tagged "meta:loc=217"http://code.activestate.com/recipes/tags/meta:loc=217/2015-01-29T20:54:38-08:00ActiveState Code RecipesBuild extension modules inplace with a Makefile (Python) 2015-01-29T20:54:38-08:00Zack Weinberghttp://code.activestate.com/recipes/users/4190298/http://code.activestate.com/recipes/579016-build-extension-modules-inplace-with-a-makefile/ <p style="color: grey"> Python recipe 579016 by <a href="/recipes/users/4190298/">Zack Weinberg</a> (<a href="/recipes/tags/compiler/">compiler</a>, <a href="/recipes/tags/module/">module</a>). </p> <p>Do you find distutils to be poorly documented, overdesigned yet still inadequate, and far too difficult to do anything out of the ordinary with? Do you find yourself wishing that you could just write a Makefile for your extension modules, if only you knew how to form the compile commands?</p> <p>Then this tool is for you. An example (GNU) makefile to use it with is embedded in the code; it assumes you save this program as <code>get-module-compile-cmds.py</code> in the same directory as the makefile. Tested with 2.7 and 3.4; may work with older versions as well.</p> <p>Installation is not currently supported; patches welcome.</p> Tic Tac Toe console game (Python) 2013-06-18T10:52:27-07:00Russel Walkerhttp://code.activestate.com/recipes/users/4186920/http://code.activestate.com/recipes/578563-tic-tac-toe-console-game/ <p style="color: grey"> Python recipe 578563 by <a href="/recipes/users/4186920/">Russel Walker</a> (<a href="/recipes/tags/ai/">ai</a>, <a href="/recipes/tags/console/">console</a>, <a href="/recipes/tags/game/">game</a>, <a href="/recipes/tags/python/">python</a>). Revision 2. </p> <p>Just a simple text based Tic Tac Toe game for human vs computer play. </p> <p>The game and AI reside in the TTTGame class. AI uses brute force search for 'perfect play'.</p> <p>The CLI class provides a text based console user interface.</p> Evaluator 2.0 (Python) 2010-11-25T18:24:09-08:00Stephen Chappellhttp://code.activestate.com/recipes/users/2608421/http://code.activestate.com/recipes/577469-evaluator-20/ <p style="color: grey"> Python recipe 577469 by <a href="/recipes/users/2608421/">Stephen Chappell</a> (<a href="/recipes/tags/evaluator/">evaluator</a>, <a href="/recipes/tags/expressions/">expressions</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/parser/">parser</a>). </p> <p>This is a complete rewrite of <a href="http://code.activestate.com/recipes/576790/">recipe 576790</a>. While aiming to maintain similar functionality and continuing its implementation for self-academic purposes, a much cleaner parser / tokenizer and operator execution engine were developed. A slightly different math syntax is supported in this version, but it is arguably better and more capable than it previously was. Base prefixes are a feature now supported, and the single downgrade is calculating with integers instead of floats.</p> An interval mapping data structure (Python) 2006-01-18T08:09:18-08:00Nicolas Lehuenhttp://code.activestate.com/recipes/users/1599156/http://code.activestate.com/recipes/457411-an-interval-mapping-data-structure/ <p style="color: grey"> Python recipe 457411 by <a href="/recipes/users/1599156/">Nicolas Lehuen</a> (<a href="/recipes/tags/algorithms/">algorithms</a>). Revision 3. </p> <p>This structure is a kind of dictionary which allows you to map data intervals to values. You can then query the structure for a given point, and it returns the value associated to the interval which contains the point. Boundary values don't need to be an integer ; indeed in the unit test I use a datetime object.</p> Simple XML serlializer/de-serializer using Python dictionaries and marshalling (Python) 2005-06-07T09:13:40-07:00Anandhttp://code.activestate.com/recipes/users/760763/http://code.activestate.com/recipes/415983-simple-xml-serlializerde-serializer-using-python-d/ <p style="color: grey"> Python recipe 415983 by <a href="/recipes/users/760763/">Anand</a> (<a href="/recipes/tags/xml/">xml</a>). Revision 2. </p> <p>This recipe presents a way of serializing &amp; de-serializing XML using the marshal module. The XML is converted to an equivalent Python dictionary first, which is marshaled to serialize it. De-serialization first unmarshals the dictionary from the file, and constructs the original XML.</p> SAX to DOM Chunker (Python) 2004-08-06T08:48:59-07:00Uche Ogbujihttp://code.activestate.com/recipes/users/509776/http://code.activestate.com/recipes/298343-sax-to-dom-chunker/ <p style="color: grey"> Python recipe 298343 by <a href="/recipes/users/509776/">Uche Ogbuji</a> (<a href="/recipes/tags/xml/">xml</a>). </p> <p>This module is similar to pulldom in that it takes a stream of SAX objects and breaks it down into chunks of DOM. The differences are that it works with any DOM implementation meeting the Python DOM conventions, and that it uses simple pattern expressions to declaratively set how the DOM chunks are partitioned, rather than requiring the user to write procedural code for this purpose. This is an updated/fixed version of code that appeared in an <a href="http://XML.com" rel="nofollow">XML.com</a> column.</p> fiber scheduler (Python) 2008-01-01T15:32:14-08:00Gertjanhttp://code.activestate.com/recipes/users/1670498/http://code.activestate.com/recipes/271607-fiber-scheduler/ <p style="color: grey"> Python recipe 271607 by <a href="/recipes/users/1670498/">Gertjan</a> . Revision 5. </p> <p>This code is part of HTTP Replicator (<a href="http://sourceforge.net/projects/http-replicator" rel="nofollow">http://sourceforge.net/projects/http-replicator</a>), a proxy server that replicates remote directory structures. The fiber module is an I/O scheduler similar to python's built-in asyncore framework, but based on generators it allows for much more freedom in choosing swich points and wait states.</p> Dump all the attributes of an object (Python) 2002-07-05T23:05:49-07:00Philip Kromerhttp://code.activestate.com/recipes/users/552075/http://code.activestate.com/recipes/137951-dump-all-the-attributes-of-an-object/ <p style="color: grey"> Python recipe 137951 by <a href="/recipes/users/552075/">Philip Kromer</a> (<a href="/recipes/tags/debugging/">debugging</a>). </p> <p>Print a nicely formatted overview of an object, including _everything_ in the object's `dir'. This is great when programming interactively.</p> <p>More comprehensive than help(), prettier than dir().</p>