I'm running into a something unexpected  for a new-style class
that has both a class attribute and __slots__ defined. If the
name of the class attribute also exists in __slots__, Python
throws an AttributeError. Is this by design (if so, why)?

class A( object ):
        __slots__ = ( 'value', )
        value = 1

        def __init__( self, value = None ):
                self.value = value or A.value

a = A()
print a.value


Traceback (most recent call last):
  File "t1.py", line 8, in ?
    a = A()
  File "t1.py", line 6, in __init__
    self.value = value or A.value
AttributeError: 'A' object attribute 'value' is read-only


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to