What's the non brute force way to filter a Python dictionary? -


i can filter following dictionary like:

data = {     1: {'name': 'stackoverflow', 'traffic': 'high'},     2: {'name': 'serverfault', 'traffic': 'low'},     3: {'name': 'superuser', 'traffic': 'low'},     4: {'name': 'mathoverflow', 'traffic': 'low'}, }  traffic = 'low'  k, v in data.items():     if v['traffic'] == traffic:         print k, v 

is there alternate way above filtering?

at level filter have describe. if you're going filter on values, you'll have process each one, one-by-one.


Comments

Popular posts from this blog

Delphi Wmi Query on a Remote Machine -