Dictionary get value
d = {}
#Not so with get:
print d.get('name')
#You may supply your own "default" value, which is then used instead of None:
print d.get('name', 'N/A')
# If the key is there, get works like ordinary dictionary lookup:
d['name'] = 'Eric'
print d.get('name')
Related examples in the same category