I am trying to check if a dictionary is empty but it doesn\'t behave properly. It just skips it and displays ONLINE without anything except of display the m
You can also use get(). Initially I believed it to only check if key existed.
>>> d = { 'a':1, 'b':2, 'c':{}} >>> bool(d.get('c')) False >>> d['c']['e']=1 >>> bool(d.get('c')) True
What I like with get is that it does not trigger an exception, so it makes it easy to traverse large structures.