Filtering defaultdict on the base of value
<p>Consider following default dict:</p>

<pre><code>data = defaultdict(list)
data['key1'] = [{'check': '', 'sth1_1':'k1', 'sth1_2':'k2'}]
data['key2'] = [{'check': '0', 'sth2_1':'k3'}, {'check': 'asd', 'sth2_2':'k4'}, {'check':'1', 'sth2_3':'k5'}]
</code></pre>

<p>and so on.. </p>

<p>I would like to filer out from <code>data</code> dictionaries (from data.values()) which value <code>'check' != '1'</code></p>

<p>For given input above i'd expect:</p>

<pre><code>defaultdict(&lt;type 'list'&gt;, {'key2': [{'sth2_3': 'k5', 'check': '1'}])
</code></pre>

<p>So far i've got:</p>

<pre><code>for k, v in data.items():
    print "k, v: ", k, v
    v[:] = [d for d in v if d.get('check') == '1']
</code></pre>

<p>But it gives me output with unwanted <code>'key1': []</code> : </p>

<pre><code>defaultdict(&lt;type 'list'&gt;, {'key2': [{'sth2_3': 'k5', 'check': '1'}], 'key1': []})
</code></pre>

<p>What would be the best pythonic way to solve that? </p>