Popular recipes by Pádraig Brady http://code.activestate.com/recipes/users/1890175/2008-07-29T14:17:02-07:00ActiveState Code Recipesformat a number for human consumption (Python)
2008-07-29T07:06:58-07:00Pádraig Bradyhttp://code.activestate.com/recipes/users/1890175/http://code.activestate.com/recipes/576385-format-a-number-for-human-consumption/
<p style="color: grey">
Python
recipe 576385
by <a href="/recipes/users/1890175/">Pádraig Brady</a>
(<a href="/recipes/tags/format/">format</a>, <a href="/recipes/tags/iec/">iec</a>, <a href="/recipes/tags/numbers/">numbers</a>, <a href="/recipes/tags/si/">si</a>, <a href="/recipes/tags/thousands/">thousands</a>).
</p>
<p>convert a number to a string representation that is more easily parsed by humans.
It supports inserting thousands separators and converting to IEC or SI units.</p>
unix subprocess wrapper (Python)
2008-07-29T07:11:17-07:00Pádraig Bradyhttp://code.activestate.com/recipes/users/1890175/http://code.activestate.com/recipes/576387-unix-subprocess-wrapper/
<p style="color: grey">
Python
recipe 576387
by <a href="/recipes/users/1890175/">Pádraig Brady</a>
(<a href="/recipes/tags/group/">group</a>, <a href="/recipes/tags/popen/">popen</a>, <a href="/recipes/tags/subprocess/">subprocess</a>, <a href="/recipes/tags/unix/">unix</a>).
Revision 2.
</p>
<p>I have used this for ages to control child processes (and all their children). Some of the existing subprocess module was based on this, but I find this simpler for my uses at least.</p>
<h4>Example:</h4>
<pre class="prettyprint"><code>import subProcess
process = subProcess.subProcess("your shell command")
process.read() #timeout is optional
handle(process.outdata, process.errdata)
del(process)
</code></pre>
filtered interpolation (Python)
2008-07-29T14:17:02-07:00Pádraig Bradyhttp://code.activestate.com/recipes/users/1890175/http://code.activestate.com/recipes/576389-filtered-interpolation/
<p style="color: grey">
Python
recipe 576389
by <a href="/recipes/users/1890175/">Pádraig Brady</a>
(<a href="/recipes/tags/filter/">filter</a>, <a href="/recipes/tags/interpolation/">interpolation</a>).
</p>
<p>I find the following 2 functions useful when programming,
when browsing objects interactively like one would do with dir.</p>
<p>Importing this module allows one to restrict the output from dir to what's required.
Note also the standard pprint module may be useful also.</p>