Supposing we have this dict:
d = {\'a\':1, \'b\': {\'c\':{}}}
What would be the most straightforward way of knowing the nesting depth>
You need to create a recursive function:
>>> def depth(d): ... if isinstance(d, dict): ... return 1 + (max(map(depth, d.values())) if d else 0) ... return 0 ... >>> d = {'a':1, 'b': {'c':{}}} >>> depth(d) 3