Message61215
If you add a property to a class with a getter and/or
setter and override the getter and/or setter in a
subclass the baseclass implementation of the methods is
still called when the property is accessed on objects
of the subclass (see below for example).
This feels like a pretty arbitrary limitation that
prevents overriding the behaviour of properties like
you would with a normal method. I'm sure there's a way
to make the property search the inheritance-hierarchy
for the provided method signature when called.
class base(object):
def get_foo(self):
print "Base get"
def set_foo(self, value):
print "Base set"
foo = property(get_foo, set_foo)
class sub(base):
def get_foo(self):
print "Sub get"
def set_foo(self, value):
print "Sub set"
s = sub()
s.foo = s.foo
-- Prints:
Base get
Base set |
|
Date |
User |
Action |
Args |
2008-01-20 09:59:43 | admin | link | issue1388872 messages |
2008-01-20 09:59:43 | admin | create | |
|