How do I pass in an argument to a list of lambdas?
<p>Intent: I'm trying to return each dictionary that contains the passed in matching keywords and values within a list of dictionaries. For example, <code>a='woot', e='1', c='duh'</code> would return only</p>

<pre><code>{'a': 'woot', 'b': 'nope', 'c': 'duh', 'd': 'rough', 'e': '1'}
</code></pre>

<p>This is what I have so far, but I don't know how to pass in an argument to a list of lambda expression which act as the filter for each dictionary in the list.</p>

<pre><code>sample_dict = [
{'a': 'woot', 'b': 'nope', 'c': 'duh', 'd': 'rough', 'e': '1'},
{'a': 'coot', 'b': 'nope', 'c': 'ruh', 'd': 'rough', 'e': '2'},
{'a': 'doot', 'b': 'nope', 'c': 'suh', 'd': 'rough', 'e': '3'},
{'a': 'soot', 'b': 'nope', 'c': 'fuh', 'd': 'rough', 'e': '4'},
{'a': 'toot', 'b': 'nope', 'c': 'cuh', 'd': 'rough', 'e': '1'}
]


def get_matched_lines(input_dict, **param):
    filters = [lambda input_dict_elem,
                      input_key=param_key,
                      input_value=param_value:
               input_dict_elem[input_key] == input_value
               for param_key, param_value in param.items()]
    return [dict_elem for dict_elem in input_dict if(all(filters))]

print(get_matched_lines(sample_dict, a='woot', e='1', c='duh'))
</code></pre>

<p>You can do this (in Python 2.7):</p>

<pre><code>def get_matched_lines(input_dict, **param):
    return [dic for dic in input_dict if all([key in dic and dic[key] == val for key, val in param.iteritems()])]
</code></pre>

<p>The same code in Python 3 is</p>

<pre><code>def get_matched_lines(input_dict, **param):
    return [dic for dic in input_dict if all([key in dic and dic[key] == val for key, val in param.items()])]    
</code></pre>

python lambda filtering list-comprehension