Is there a smart pythonic way to check if there is an item (key,value) in a dict?
a={\'a\':1,\'b\':2,\'c\':3} b={\'a\':1} c={\'a\':2} b in a: --> True c
For python 3.x use if key in dict
if key in dict
See the sample code
#!/usr/bin/python a={'a':1,'b':2,'c':3} b={'a':1} c={'a':2} mylist = [a, b, c] for obj in mylist: if 'b' in obj: print(obj['b']) Output: 2