def __getitem__(self, item):
try:<EOL><INDENT>return dict.__getitem__(self, item)<EOL><DEDENT>except KeyError:<EOL><INDENT>tmp = type(self)()<EOL>self[item] = tmp<EOL>return tmp<EOL><DEDENT>
Tries to get the item, and if it's not found creates it
Credit to: http://tiny.cc/qerr7x