[ python-Feature Requests-1388872 ] Polymorphic getters / setters

SourceForge.net noreply at sourceforge.net
Fri Dec 23 14:08:36 CET 2005


Feature Requests item #1388872, was opened at 2005-12-23 14:08
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1388872&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Adde (trialcode)
Assigned to: Nobody/Anonymous (nobody)
Summary: Polymorphic getters / setters

Initial Comment:
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

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1388872&group_id=5470


More information about the Python-bugs-list mailing list