I find it more convenient to access dict keys as obj.foo instead of obj[\'foo\'], so I wrote this snippet:
obj.foo
obj[\'foo\']
class AttributeDict(dict
class AttrDict(dict): def __init__(self): self.__dict__ = self if __name__ == '____main__': d = AttrDict() d['ray'] = 'hope' d.sun = 'shine' >>> Now we can use this . notation print d['ray'] print d.sun