Modify passed, nested dict/list
<p>I was thinking of writing a function to normalize some data. A simple approach is</p>

<pre><code>def normalize(l, aggregate=sum, norm_by=operator.truediv):
    aggregated=aggregate(l)
    for i in range(len(l)):
        l[i]=norm_by(l[i], aggregated)

l=[1,2,3,4]
normalize(l)
l -&gt; [0.1, 0.2, 0.3, 0.4]
</code></pre>

<p>However for nested lists and dicts where I want to normalize over an inner index this doesnt work. I mean I'd like to get</p>

<pre><code>l=[[1,100],[2,100],[3,100],[4,100]]
normalize(l, ?? )
l -&gt; [[0.1,100],[0.2,100],[0.3,100],[0.4,100]]
</code></pre>

<p>Any ideas how I could implement such a normalize function?</p>

<p>Maybe it would be crazy cool to write</p>

<pre><code>normalize(l[...][0])
</code></pre>

<p>Is it possible to make this work?? Or any other ideas?</p>

<p>Also not only lists but also dict could be nested. Hmm...</p>

<p>EDIT:
I just found out that numpy offers such a syntax (for lists however). Anyone know how I would implement the ellipsis trick myself?</p>
