filter uses the method given to filter out the elements that returns true when applying the method.
This is an example.
pair = \
[
{'group': 'b', 'method': 'test'},
{'group': 'a', 'method': 'test'}
]
print map(lambda x: x['group'] == 'a', pair)
print filter(lambda x: x['group'] == 'a', pair)
This is the result.
[False, True]
[{'group': 'a', 'method': 'test'}]
No comments:
Post a Comment