Popular recipes by David Moss http://code.activestate.com/recipes/users/4124829/2009-05-20T16:22:37-07:00ActiveState Code RecipesDot-style nested lookups over dictionary based data structures (Python)
2008-12-14T14:32:59-08:00David Mosshttp://code.activestate.com/recipes/users/4124829/http://code.activestate.com/recipes/576586-dot-style-nested-lookups-over-dictionary-based-dat/
<p style="color: grey">
Python
recipe 576586
by <a href="/recipes/users/4124829/">David Moss</a>
(<a href="/recipes/tags/access/">access</a>, <a href="/recipes/tags/attribute/">attribute</a>, <a href="/recipes/tags/dictionaries/">dictionaries</a>).
Revision 2.
</p>
<p>This recipe allows you to present dictionary based nested data stuctures in your Python code as objects with nested attributes.</p>
<p>It provides dot ('.') based attribute lookups, like this :-</p>
<pre class="prettyprint"><code>>>> x = d.foo.bar.baz
</code></pre>
<p>instead of the usual (and longer) Python dictionary syntax lookups :-</p>
<pre class="prettyprint"><code>>>> x = d['foo']['bar']['baz']
</code></pre>
<p>This recipe saves you <em>lot</em> of typing!</p>
<p>For simplicity and readability this particular version show a read only lookup class.</p>
Capitalizing ISO 3166 country names correctly (Python)
2009-05-20T16:22:37-07:00David Mosshttp://code.activestate.com/recipes/users/4124829/http://code.activestate.com/recipes/576768-capitalizing-iso-3166-country-names-correctly/
<p style="color: grey">
Python
recipe 576768
by <a href="/recipes/users/4124829/">David Moss</a>
(<a href="/recipes/tags/3166/">3166</a>, <a href="/recipes/tags/capitalization/">capitalization</a>, <a href="/recipes/tags/iso/">iso</a>).
</p>
<p>A simple 3 function utility library for downloading, parsing and capitalizing ISO 3166 country names.</p>
Interleaving file lines using iterators (Python)
2009-02-23T04:07:37-08:00David Mosshttp://code.activestate.com/recipes/users/4124829/http://code.activestate.com/recipes/576665-interleaving-file-lines-using-iterators/
<p style="color: grey">
Python
recipe 576665
by <a href="/recipes/users/4124829/">David Moss</a>
(<a href="/recipes/tags/file/">file</a>, <a href="/recipes/tags/generators/">generators</a>, <a href="/recipes/tags/iterators/">iterators</a>, <a href="/recipes/tags/manipulation/">manipulation</a>).
</p>
<p>Accepts one of more files and/or globs and interleaves the lines from each writing the result to stdout.</p>
Converting arbitrary size Python integers to packed binary data strings (Python)
2009-01-16T13:27:29-08:00David Mosshttp://code.activestate.com/recipes/users/4124829/http://code.activestate.com/recipes/576617-converting-arbitrary-size-python-integers-to-packe/
<p style="color: grey">
Python
recipe 576617
by <a href="/recipes/users/4124829/">David Moss</a>
(<a href="/recipes/tags/binary/">binary</a>, <a href="/recipes/tags/integers/">integers</a>, <a href="/recipes/tags/pack/">pack</a>, <a href="/recipes/tags/struct/">struct</a>, <a href="/recipes/tags/unpack/">unpack</a>, <a href="/recipes/tags/unsigned/">unsigned</a>).
</p>
<p>Routines for converting <strong>large</strong> unsigned arbitrary sized Python integers to packed binary data strings and vice versa.</p>