Popular recipes by Jimmy Retzlaff http://code.activestate.com/recipes/users/98735/2005-01-03T20:20:38-08:00ActiveState Code RecipesTerminating a subprocess on Windows (Python)
2004-11-24T12:52:28-08:00Jimmy Retzlaffhttp://code.activestate.com/recipes/users/98735/http://code.activestate.com/recipes/347462-terminating-a-subprocess-on-windows/
<p style="color: grey">
Python
recipe 347462
by <a href="/recipes/users/98735/">Jimmy Retzlaff</a>
(<a href="/recipes/tags/sysadmin/">sysadmin</a>).
</p>
<p>The new subprocess module in Python 2.4 (also available for 2.2 and 2.3 at <a href="http://effbot.org/downloads/#subprocess" rel="nofollow">http://effbot.org/downloads/#subprocess</a>) allows access to the handle of any newly created subprocess. You can use this handle to terminate subprocesses using either ctypes or the pywin32 extensions.</p>
attrdict - a dict whose items can also be accessed as member variables (Python)
2005-01-03T20:20:38-08:00Jimmy Retzlaffhttp://code.activestate.com/recipes/users/98735/http://code.activestate.com/recipes/361668-attrdict-a-dict-whose-items-can-also-be-accessed-a/
<p style="color: grey">
Python
recipe 361668
by <a href="/recipes/users/98735/">Jimmy Retzlaff</a>
(<a href="/recipes/tags/shortcuts/">shortcuts</a>).
Revision 2.
</p>
<p>Sometimes accessing dictionary items as if they were member variables can be convenient.</p>
Load data in a web browser without using temp files (Python)
2004-12-21T07:50:58-08:00Jimmy Retzlaffhttp://code.activestate.com/recipes/users/98735/http://code.activestate.com/recipes/347810-load-data-in-a-web-browser-without-using-temp-file/
<p style="color: grey">
Python
recipe 347810
by <a href="/recipes/users/98735/">Jimmy Retzlaff</a>
(<a href="/recipes/tags/shortcuts/">shortcuts</a>).
Revision 3.
</p>
<p>It is often nice to display something in a web browser, perhaps as an easy way to display rich output or for testing purposes. Sometimes the baggage of a temporary file is not desired when doing this.</p>
A Generator That Helps Simplify Queue Consumers (Python)
2003-12-04T17:29:35-08:00Jimmy Retzlaffhttp://code.activestate.com/recipes/users/98735/http://code.activestate.com/recipes/252498-a-generator-that-helps-simplify-queue-consumers/
<p style="color: grey">
Python
recipe 252498
by <a href="/recipes/users/98735/">Jimmy Retzlaff</a>
(<a href="/recipes/tags/shortcuts/">shortcuts</a>).
</p>
<p>My Queue usage typically involves a producer thread and a consumer thread. The producer calls queue.put(value) until it's done at which point it calls queue.put(sentinel). My consumers almost always look like this:</p>
<p>while True:
value = queue.get()
if value != sentinel:
# do something with value
else:
break</p>
<p>That logic can be abstracted away into a generator function that allows consumer code to look like this instead:</p>
<p>for value in iterQueue(queue, sentinel):
# do something with value</p>
Simplify Assignment to Member Variables (Python)
2002-10-19T04:09:35-07:00Jimmy Retzlaffhttp://code.activestate.com/recipes/users/98735/http://code.activestate.com/recipes/157572-simplify-assignment-to-member-variables/
<p style="color: grey">
Python
recipe 157572
by <a href="/recipes/users/98735/">Jimmy Retzlaff</a>
(<a href="/recipes/tags/shortcuts/">shortcuts</a>).
</p>
<p>Writing code like this can be very repetitive:</p>
<p>class c:
def __init__(self, memberVariableNumberOne, memberVariableNumberTwo):
self. memberVariableNumberOne = memberVariableNumberOne
self. memberVariableNumberTwo = memberVariableNumberTwo</p>
<p>The above can be changed to:</p>
<p>class c:
def __init__(self, memberVariableNumberOne, memberVariableNumberTwo):
AssignMemberVariablesFromParameters()</p>
Loose Coupling (Python)
2001-10-16T07:44:18-07:00Jimmy Retzlaffhttp://code.activestate.com/recipes/users/98735/http://code.activestate.com/recipes/81983-loose-coupling/
<p style="color: grey">
Python
recipe 81983
by <a href="/recipes/users/98735/">Jimmy Retzlaff</a>
(<a href="/recipes/tags/oop/">oop</a>).
Revision 2.
</p>
<p>The "broadcaster" and "broker" modules enable loose coupling between objects in a running application.</p>