I want to define a class like this:
class Test:
_ID = itertools.count()
def __init__(self):
self.id = next(self._ID)
self.__setattr__('_dict', {})
def __getattr__(self, key):
return self._dict[key]
def __setattr__(self, key, value):
self._dict[key] = value
What is the best approach in this case?