Is there a recursive version of the dict.get() built-in?
A very common pattern to do this is to use an empty dict as your default: d.get(‘foo’, {}).get(‘bar’) If you have more than a couple of keys, you could use reduce (note that in Python 3 reduce must be imported: from functools import reduce) to apply the operation multiple times reduce(lambda c, k: c.get(k, {}), … Read more