python remove obect from array using condition
<p>I have a list of dictionaries like below:</p>

<pre><code>tt = [
{
     'property1': 'value1',
     'property2': 'value2',
     'property3': 'value3'
},
{
     'property1': 'value4',
     'property2': 'value5',
     'property3': 'value6'
},
..............................
.............................
]
</code></pre>

<p>How i can remove <code>'property3' : 'value6'</code> from above list of dictionaries?</p>

<p>To be precise, i need to remove all instances of key('property3') with specific value('value6') from all dictionaries in the list?</p>

<p>I am in need of fastest method, because list can be vary large.</p>

<p>This should do it. Fairly straight forward so I won't explain it. Good Luck</p>

<pre><code>def search(dict, key=None, val=None):
    c_dict = copy.deepcopy(dict)
    for i, n in enumerate(dict):
        for k, v in n.iteritems():
            if key and val and k == key and val == v:
                c_dict[i].pop(k)
            elif key and k == key:
                c_dict[i].pop(k)
            elif v and val == v:
                c_dict[i].pop(k)
            else:
                continue
    return c_dict

print search(d, 'property3', 'value6')
</code></pre>

python python-3.x