Skip to content

Instantly share code, notes, and snippets.

@zachwill
Created September 18, 2011 03:39
Show Gist options
  • Save zachwill/1224695 to your computer and use it in GitHub Desktop.
Save zachwill/1224695 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
"""For ctbarna."""
list_of_dicts = [
{'key_1': 'value_1', 'key_2': 'value_2'},
{'key_1': {'inception_key': 'inception_value'}, 'key_2': 'value_2'},
{'key_1': 'value_1', 'key_2': 'value_2'},
]
def print_key(dictionary):
"""For mapping over list of dicts."""
for key in dictionary:
if isinstance(dictionary[key], dict):
print dictionary['key_2']
map(print_key, list_of_dicts)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment