Popular recipes by Glenn Hutchings http://code.activestate.com/recipes/users/4175415/2013-08-22T07:15:47-07:00ActiveState Code RecipesContinued fractions (Python)
2013-08-22T07:15:47-07:00Glenn Hutchingshttp://code.activestate.com/recipes/users/4175415/http://code.activestate.com/recipes/578647-continued-fractions/
<p style="color: grey">
Python
recipe 578647
by <a href="/recipes/users/4175415/">Glenn Hutchings</a>
(<a href="/recipes/tags/decimal/">decimal</a>, <a href="/recipes/tags/fractions/">fractions</a>).
Revision 2.
</p>
<p>A class representing a <a href="https://en.wikipedia.org/wiki/Continued_fraction">continued fraction</a>.</p>
Flexible datetime parsing (Python)
2012-08-21T07:35:34-07:00Glenn Hutchingshttp://code.activestate.com/recipes/users/4175415/http://code.activestate.com/recipes/578245-flexible-datetime-parsing/
<p style="color: grey">
Python
recipe 578245
by <a href="/recipes/users/4175415/">Glenn Hutchings</a>
(<a href="/recipes/tags/datetime/">datetime</a>, <a href="/recipes/tags/parsing/">parsing</a>).
</p>
<p>The strptime() method of datetime accepts a format string that you have to specify in advance. What if you want to be more flexible in the kinds of date your program accepts? Here's a recipe for a function that tries many different formats until it finds one that works.</p>
State tree (Python)
2012-06-06T14:38:21-07:00Glenn Hutchingshttp://code.activestate.com/recipes/users/4175415/http://code.activestate.com/recipes/578159-state-tree/
<p style="color: grey">
Python
recipe 578159
by <a href="/recipes/users/4175415/">Glenn Hutchings</a>
(<a href="/recipes/tags/deque/">deque</a>).
</p>
<p>Explore a tree of states to find a goal state.</p>
Benford's Law demo (Python)
2010-10-19T10:56:51-07:00Glenn Hutchingshttp://code.activestate.com/recipes/users/4175415/http://code.activestate.com/recipes/577431-benfords-law-demo/
<p style="color: grey">
Python
recipe 577431
by <a href="/recipes/users/4175415/">Glenn Hutchings</a>
(<a href="/recipes/tags/benford/">benford</a>, <a href="/recipes/tags/matplotlib/">matplotlib</a>, <a href="/recipes/tags/plotting/">plotting</a>).
</p>
<p>Here's a simple program to demonstrate <a href="http://en.wikipedia.org/wiki/Benford%27s_law">Benford's Law</a>, which also shows the simple power of <a href="http://matplotlib.sourceforge.net">matplotlib</a>. It reads from a bunch of files (or stdin, if none specified), extracts the leading digits of all number-like strings found, and plots the distribution in a window together with the expected result if Benford's law applies.</p>