I want to keep a dictionary of my custom classes so that I can dynamically instantiate them from other dictionaries (loaded from db), but I'm not sure what to store.
class_register = {}
class Foo(object):
def __init__(self, **kwargs):
class_register[self.__class__.__name__] = ?? # what to store here?
self.__dict__.update(kwargs)
new_instance = class_register[result['class_name']](**result['data'])
Open to any suggestions.
self.__class__? I'm not too sure why you'd need to do this. Can you explain your scenario a little more?