Multilevel Dictionaries in Python

As an experienced Perl programmer, I have been dealing with nested hashrefs of hashrefs. (Those not familiar with Perl: hashref is short for hash reference. Hash is also known as associative array.)

In Perl, we can just arbitrarily create hashrefs of hashrefs on the fly, e.g.:

In Python, not so easy. This will give you a KeyError exception.

My friend Kamal Advani (thanks, man!) suggested this to me:

Use at your own risk. I do not provide any support for this. You have my permission to copy it.