Skip to content

Instantly share code, notes, and snippets.

@pythonjunkie
Created August 29, 2012 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pythonjunkie/3517111 to your computer and use it in GitHub Desktop.
Save pythonjunkie/3517111 to your computer and use it in GitHub Desktop.
Extracting key value pairs from a dictionary
def extract(dictin):
dictout={}
for key, value in dictin.iteritems():
print('key:%s \t Value:%s' % (key,value))
if isinstance(value, dict):
extract(value, dictout)
elif isinstance(value, list):
for i in value:
extract(i,dictout)
else:
dictout[key] = value
print('Dictout:%s' % dictout)
return dictout
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment