Popular recipes by d.schlabing http://code.activestate.com/recipes/users/4168903/2010-03-01T03:22:43-08:00ActiveState Code RecipesLogging asserts (Python)
2010-03-01T03:22:43-08:00d.schlabinghttp://code.activestate.com/recipes/users/4168903/http://code.activestate.com/recipes/577074-logging-asserts/
<p style="color: grey">
Python
recipe 577074
by <a href="/recipes/users/4168903/">d.schlabing</a>
(<a href="/recipes/tags/logging/">logging</a>).
Revision 2.
</p>
<p>This tries to marry assert statements with logging. If you use asserts together with logging and the script stops because an assertion is not fulfilled, you will not find any information about this in the logs.
Unless you do something like this:</p>
<pre class="prettyprint"><code>meal = ["eggs", "bacon", "spam"]
try:
assert "spam" not in meal, "But I don't like spam!"
except AssertionError:
log.exception("But I don't like spam!")
raise
</code></pre>
<p>With the proposed recipe a somewhat similar behaviour can be achieved by:</p>
<pre class="prettyprint"><code>log_assert("spam" not in meal, "But I don't like spam!")
</code></pre>
Calculations on huge (memmap-)arrays (Python)
2009-05-05T10:19:37-07:00d.schlabinghttp://code.activestate.com/recipes/users/4168903/http://code.activestate.com/recipes/576739-calculations-on-huge-memmap-arrays/
<p style="color: grey">
Python
recipe 576739
by <a href="/recipes/users/4168903/">d.schlabing</a>
(<a href="/recipes/tags/memmap/">memmap</a>, <a href="/recipes/tags/numpy/">numpy</a>, <a href="/recipes/tags/oop/">oop</a>).
Revision 2.
</p>
<p>This is a way of doing calculations on whole arrays that might be to big to fit into memory.</p>
Heise mp3 downloader (Python)
2009-01-17T11:51:39-08:00d.schlabinghttp://code.activestate.com/recipes/users/4168903/http://code.activestate.com/recipes/576618-heise-mp3-downloader/
<p style="color: grey">
Python
recipe 576618
by <a href="/recipes/users/4168903/">d.schlabing</a>
(<a href="/recipes/tags/oop/">oop</a>, <a href="/recipes/tags/script/">script</a>, <a href="/recipes/tags/threads/">threads</a>).
</p>
<p>This little script presents new heise-news-articles individually by title and asks if it should download the corresponding mp3-file.</p>