Overriding methods in classes that use property()
Edmund Lian
elian at inbrief.net
Mon Apr 22 11:19:39 EDT 2002
Hi,
When I run the code appended below, class B inherits all the methods of
class A, including the property() definition as I would expect.
Unfortunately, class C also does the same; I cannot override class A's
setVal method. Is this a bug, or do I have to do something different (and
unexpected) with Python 2.2's new style classes?
...Edmund.
class A(object):
def __init__(self):
self._val = None
def setVal(self, value):
self._val = value
def getVal (self):
return self._val
val = property(getVal, setVal)
class B(A):
pass
class C(A):
def setVal(self, value):
self._val = 'Huh?'
More information about the Python-list
mailing list