Does anyone know why you can't assign a custom mapping type to an object's __dict__?
py> class M(object): ... def __getitem__(self, key): ... return 42 ... def __setitem__(self, key, value): ... pass ... py> class C(object): ... pass ... py> c = C() py> c.__dict__ = M() Traceback (most recent call last): File "<interactive input>", line 1, in ? TypeError: __dict__ must be set to a dictionary
I looked at the source in typeobject.c (where this error originates), but I'm not fluent enough in CPython yet to be able to tell why a true dict type is preferred here over just a mapping type...
STeVe -- http://mail.python.org/mailman/listinfo/python-list