Popular recipes by Ian Eloff http://code.activestate.com/recipes/users/2227021/2009-05-30T16:35:27-07:00ActiveState Code RecipesPartition an iterable into n lists (Python)
2009-05-30T16:35:27-07:00Ian Eloffhttp://code.activestate.com/recipes/users/2227021/http://code.activestate.com/recipes/576785-partition-an-iterable-into-n-lists/
<p style="color: grey">
Python
recipe 576785
by <a href="/recipes/users/2227021/">Ian Eloff</a>
(<a href="/recipes/tags/iterator/">iterator</a>, <a href="/recipes/tags/partition/">partition</a>).
</p>
<p>This could also be easily modified to return n iterators, but was outside of my needs. Handy for splitting up the workload for use with multiple threads/processes.</p>
wxPython LED control (Python)
2007-09-30T14:39:03-07:00Ian Eloffhttp://code.activestate.com/recipes/users/2227021/http://code.activestate.com/recipes/533125-wxpython-led-control/
<p style="color: grey">
Python
recipe 533125
by <a href="/recipes/users/2227021/">Ian Eloff</a>
.
</p>
<p>A LED control that can have different colors, each associated with a state. The default is green, amber, and red. Calling ledControl.State = 1 will set the color of the LED to the color by that index (given as a list in the constructor.) In the default case 0 is red, 1 is amber, and 2 is green.</p>
Automatic ref-count management in C++ using a smart ptr (Python)
2007-08-14T15:41:44-07:00Ian Eloffhttp://code.activestate.com/recipes/users/2227021/http://code.activestate.com/recipes/528875-automatic-ref-count-management-in-c-using-a-smart-/
<p style="color: grey">
Python
recipe 528875
by <a href="/recipes/users/2227021/">Ian Eloff</a>
(<a href="/recipes/tags/extending/">extending</a>).
</p>
<p>Managing ref-counting is a complex and error prone business. If you choose C++ to extend or embed Python, you can simply use a modification on std::auto_ptr. Instead of calling delete on the managed pointer, it will decref it.</p>
<p>So now you can do:</p>
<p>auto_py str = PyStr_FromString("Hello World!");</p>
<p>and forget about having to decref it altogether! Just like auto_ptr you can get the PyObject * with get(), release it from managed control with release(), and rebind it with reset(new_ptr). You can also incref it by calling inc(), but be cautious as you can easily create a leak by increfing once to much.</p>