Popular recipes by Edward Loper http://code.activestate.com/recipes/users/2637812/2011-01-10T02:27:08-08:00ActiveState Code RecipesPython Binary Search Tree (Python) 2011-01-10T02:27:08-08:00Edward Loperhttp://code.activestate.com/recipes/users/2637812/http://code.activestate.com/recipes/577540-python-binary-search-tree/ <p style="color: grey"> Python recipe 577540 by <a href="/recipes/users/2637812/">Edward Loper</a> (<a href="/recipes/tags/algorithms/">algorithms</a>, <a href="/recipes/tags/maximum/">maximum</a>, <a href="/recipes/tags/minimum/">minimum</a>, <a href="/recipes/tags/search/">search</a>, <a href="/recipes/tags/sort/">sort</a>). Revision 2. </p> <p>A data structure that holds a sorted collection of values, and supports efficient insertion, deletion, sorted iteration, and min/max finding. Values may sorted either based on their natural ordering, or on a key function (specified as an argument to the search tree's constructor). The search tree may contain duplicate values (or multiple values with equal keys) -- the ordering of such values is undefined.</p> <p>This implementation was made with efficiency in mind. In particular, it is more than twice as fast as the other native-Python implementations I tried (which all use objects to store search tree nodes).</p> <p>See also: <a href="http://en.wikipedia.org/wiki/Binary_search_tree">http://en.wikipedia.org/wiki/Binary_search_tree</a>, <a href="http://en.wikipedia.org/wiki/A*_search_algorithm">http://en.wikipedia.org/wiki/A*_search_algorithm</a></p> Using terminfo for portable color output & cursor control (Python) 2006-03-27T19:20:16-08:00Edward Loperhttp://code.activestate.com/recipes/users/2637812/http://code.activestate.com/recipes/475116-using-terminfo-for-portable-color-output-cursor-co/ <p style="color: grey"> Python recipe 475116 by <a href="/recipes/users/2637812/">Edward Loper</a> (<a href="/recipes/tags/text/">text</a>). Revision 3. </p> <p>The curses module defines several functions (based on terminfo) that can be used to perform lightweight cursor control &amp; output formatting (color, bold, etc). These can be used without invoking curses mode (curses.initwin) or using any of the more heavy-weight curses functionality. This recipe defines a TerminalController class, which can make portable output formatting very simple. Formatting modes that are not supported by the terminal are simply omitted.</p> Regular expression for python string literals (Python) 2006-03-10T20:52:36-08:00Edward Loperhttp://code.activestate.com/recipes/users/2637812/http://code.activestate.com/recipes/475109-regular-expression-for-python-string-literals/ <p style="color: grey"> Python recipe 475109 by <a href="/recipes/users/2637812/">Edward Loper</a> (<a href="/recipes/tags/programs/">programs</a>). </p> <p>A regular expression that matches Python string literals. Tripple-quoted, unicode, and raw strings are supported.</p>