dict to class — рекурсивно

# convert a dictionary to a class
class Struct(object):
def __init__(self, adict):
"""Convert a dictionary to a class

@param :adict Dictionary
"""
self.__dict__.update(adict)
for k, v in adict.items():
if isinstance(v, dict):
self.__dict__[k] = Struct(v)

def get_object(adict):
"""Convert a dictionary to a class

@param :adict Dictionary
@return :class:Struct
"""
return Struct(adict)

Рецепт: