3 ms·
Seems like a lot of work and magic when compared to, say: class Box(UserDict): def __getattr__(self, key): return self.__getitem__(key)
by falcolas 10y ago
Seems like a lot of work and magic when compared to, say:
class Box(UserDict):
def __getattr__(self, key):
return self.__getitem__(key)
def __setattr__(self, key, value):
return self.__setitem__(key, value)
I know a few folks who prefer this method of access, so I can't naysay against it too much, but personally I just prefer plain dictionaries.
- masklinn 10y ago> Box(UserDict): There's no reason to use UserDict, just extend `dict` directly, or implement `MutableMapping` instead. UserDict hasn't been useful since the types/class unification back in… Python 2.3 I think?