Skip to content

Instantly share code, notes, and snippets.

View qoda's full-sized avatar

Jonathan Bydendyk qoda

View GitHub Profile
@qoda
qoda / attrdict.py
Last active August 29, 2015 13:56
Convert Dict to Object
class AttrDict(dict):
"""
Convert a dict to an object.
"""
def __init__(self, new_dict):
self.__dict__.update(new_dict)
for key, val in new_dict.items():
if isinstance(val, dict):
self.__dict__[key] = AttrDict(val)