Unexpected behavior of read only attributes and super
Samuel M.Smith
smithsm at samuelsmith.org
Tue Dec 6 15:53:31 EST 2005
Even more strangeness
If I define the class to use slots
class SD(dict):
__slots__ = ['a','b']
s = SD()
>>> s.__iter__
<method-wrapper object at 0x2808f0>
>>> s.__iter__ = 5
Traceback (most recent call last):
File "<stdin>", line 1, in ?
AttributeError: 'SD' object attribute '__iter__' is read-only
Then I get the read only exception but not because it was read only
but because
I defined slots.
This looks like a logic error in how setattr is working in in the
superclass dict
**********************************************************************
Samuel M. Smith Ph.D.
2966 Fort Hill Road
Eagle Mountain, Utah 84043
801-768-2768 voice
801-768-2769 fax
**********************************************************************
"The greatest source of failure and unhappiness in the world is
giving up what we want most for what we want at the moment"
**********************************************************************
More information about the Python-list
mailing list