This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Polymorphic getters / setters
Type: Stage:
Components: Interpreter Core Versions: Python 2.4
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, trialcode
Priority: normal Keywords:

Created on 2005-12-23 11:26 by trialcode, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg27132 - (view) Author: Adde (trialcode) Date: 2005-12-23 11:26
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.

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
msg27133 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2005-12-23 11:32
Logged In: YES 
user_id=1188172

This is expected behavior. The property is created with
references to the specific methods "base.get_foo" and
"base.set_foo".
History
Date User Action Args
2022-04-11 14:56:14adminsetgithub: 42719
2005-12-23 11:26:53trialcodecreate