Popular recipes by Daniel Cohn http://code.activestate.com/recipes/users/4172918/2012-03-14T15:12:39-07:00ActiveState Code RecipesRPDB (RobotPythonDebugger) -- a smarter way to debug robotframework tests (Python)
2012-03-14T15:12:39-07:00Daniel Cohnhttp://code.activestate.com/recipes/users/4172918/http://code.activestate.com/recipes/578073-rpdb-robotpythondebugger-a-smarter-way-to-debug-ro/
<p style="color: grey">
Python
recipe 578073
by <a href="/recipes/users/4172918/">Daniel Cohn</a>
(<a href="/recipes/tags/debugging/">debugging</a>, <a href="/recipes/tags/decorator/">decorator</a>, <a href="/recipes/tags/pdb/">pdb</a>, <a href="/recipes/tags/redirect/">redirect</a>, <a href="/recipes/tags/robot/">robot</a>, <a href="/recipes/tags/rpdb/">rpdb</a>, <a href="/recipes/tags/stdin/">stdin</a>, <a href="/recipes/tags/stdout/">stdout</a>).
</p>
<p>Robotframework (<a href="http://code.google.com/p/robotframework/" rel="nofollow">http://code.google.com/p/robotframework/</a>) is a tool used to run functional tests against a variety of targets. Tests are organized in the form of keyword tsv or html files, which map input parameters to keyword-argument methods in the test suite. Robot includes a fairly advanced logging mechanism, which is cool -- until you try to debug anything. Debugging is made difficult because robot steals stdin and stdout when it is run, which means bye-bye debugging in the terminal. rpdb solves this in a KISS simple way.</p>
Yet another roundrobin (Python)
2010-07-19T13:53:41-07:00Daniel Cohnhttp://code.activestate.com/recipes/users/4172918/http://code.activestate.com/recipes/577309-yet-another-roundrobin/
<p style="color: grey">
Python
recipe 577309
by <a href="/recipes/users/4172918/">Daniel Cohn</a>
(<a href="/recipes/tags/collections/">collections</a>, <a href="/recipes/tags/itertools/">itertools</a>, <a href="/recipes/tags/roundrobin/">roundrobin</a>).
Revision 2.
</p>
<p>This recipe provides a decently simple implementation of a roundrobin using itertools and deque.</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>
Find file in subdirectory (Python)
2010-02-02T11:35:53-08:00Daniel Cohnhttp://code.activestate.com/recipes/users/4172918/http://code.activestate.com/recipes/577027-find-file-in-subdirectory/
<p style="color: grey">
Python
recipe 577027
by <a href="/recipes/users/4172918/">Daniel Cohn</a>
(<a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/find/">find</a>, <a href="/recipes/tags/subdirectory/">subdirectory</a>).
Revision 2.
</p>
<p>Walks subdirectories to find a file and returns . Default start location is the current working directory. Optionally, a different directory can be set as the search's starting location.</p>
Access grep from python (Python)
2010-02-24T08:30:25-08:00Daniel Cohnhttp://code.activestate.com/recipes/users/4172918/http://code.activestate.com/recipes/577069-access-grep-from-python/
<p style="color: grey">
Python
recipe 577069
by <a href="/recipes/users/4172918/">Daniel Cohn</a>
(<a href="/recipes/tags/files/">files</a>, <a href="/recipes/tags/grep/">grep</a>, <a href="/recipes/tags/linux/">linux</a>).
</p>
<p>The recipe below passes a filename and an argument to grep, returning the stdout and stderr. Each line in the stdout will have its line number prepended.</p>
Design Pattern -- Inherit from an instance (Python)
2010-02-22T06:04:16-08:00Daniel Cohnhttp://code.activestate.com/recipes/users/4172918/http://code.activestate.com/recipes/577026-design-pattern-inherit-from-an-instance/
<p style="color: grey">
Python
recipe 577026
by <a href="/recipes/users/4172918/">Daniel Cohn</a>
(<a href="/recipes/tags/design_pattern/">design_pattern</a>, <a href="/recipes/tags/factory_class/">factory_class</a>, <a href="/recipes/tags/inheritance/">inheritance</a>, <a href="/recipes/tags/instance/">instance</a>).
Revision 4.
</p>
<p>Take an instance (call it foo) and create a factory class (call it InstanceFactory) that produces foo's. Then inherit from InstanceFactory.</p>