Popular recipes tagged "loop"http://code.activestate.com/recipes/tags/loop/2014-03-08T13:09:41-08:00ActiveState Code RecipesFactorial (Python) 2014-03-08T13:09:41-08:00Johnhttp://code.activestate.com/recipes/users/4189390/http://code.activestate.com/recipes/578848-factorial/ <p style="color: grey"> Python recipe 578848 by <a href="/recipes/users/4189390/">John</a> (<a href="/recipes/tags/factorial/">factorial</a>, <a href="/recipes/tags/loop/">loop</a>, <a href="/recipes/tags/loops/">loops</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/range/">range</a>, <a href="/recipes/tags/simple/">simple</a>). </p> <p>Just a simple factorial program I made in Python 3.</p> Retry loop (Python) 2013-05-23T20:45:01-07:00Ryan Nowakowskihttp://code.activestate.com/recipes/users/4186624/http://code.activestate.com/recipes/578527-retry-loop/ <p style="color: grey"> Python recipe 578527 by <a href="/recipes/users/4186624/">Ryan Nowakowski</a> (<a href="/recipes/tags/exception/">exception</a>, <a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/loop/">loop</a>, <a href="/recipes/tags/retry/">retry</a>, <a href="/recipes/tags/timeout/">timeout</a>). </p> <p>Encapsulates the logic of a retry loop using a generator function.</p> Retry loop (Python) 2013-05-24T05:19:50-07:00Oren Tiroshhttp://code.activestate.com/recipes/users/2033964/http://code.activestate.com/recipes/578163-retry-loop/ <p style="color: grey"> Python recipe 578163 by <a href="/recipes/users/2033964/">Oren Tirosh</a> (<a href="/recipes/tags/exception/">exception</a>, <a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/loop/">loop</a>, <a href="/recipes/tags/retry/">retry</a>, <a href="/recipes/tags/timeout/">timeout</a>). Revision 4. </p> <p>Encapsulates the logic of a retry loop using a generator function.</p> Windowing an iterable with itertools (Python) 2010-04-15T18:45:41-07:00Daniel Cohnhttp://code.activestate.com/recipes/users/4172918/http://code.activestate.com/recipes/577196-windowing-an-iterable-with-itertools/ <p style="color: grey"> Python recipe 577196 by <a href="/recipes/users/4172918/">Daniel Cohn</a> (<a href="/recipes/tags/generator/">generator</a>, <a href="/recipes/tags/iterable/">iterable</a>, <a href="/recipes/tags/iterator/">iterator</a>, <a href="/recipes/tags/loop/">loop</a>, <a href="/recipes/tags/peeking/">peeking</a>, <a href="/recipes/tags/window/">window</a>). </p> <p>Oftentimes a programmer needs to peek into an iterator without advancing it, a task for which many good solutions already exist. But what if the intrepid coder needs a fast and pythonic way to 'window' the data? This recipe demonstrates how to wrap any iterable with a class that adds two methods, prev and peek.</p> Another use for lambdas and function references (Python) 2009-02-27T06:20:33-08:00Kaushik Ghosehttp://code.activestate.com/recipes/users/4166965/http://code.activestate.com/recipes/576672-another-use-for-lambdas-and-function-references/ <p style="color: grey"> Python recipe 576672 by <a href="/recipes/users/4166965/">Kaushik Ghose</a> (<a href="/recipes/tags/function_reference/">function_reference</a>, <a href="/recipes/tags/lambda/">lambda</a>, <a href="/recipes/tags/loop/">loop</a>). </p> <p>I was writing code to do bootstrapping on a set of data. I wanted a test case where if I asked for one bootstrap I would be returned the original data. lambdas and function references saved me from inefficient code.</p>