Newbie: Inheritance of accessors

Will Fitzgerald fitzgerald at inetmi.com
Wed Oct 16 02:31:43 CEST 2002


I'm curious about accessors being inherited from parent classes. Given 
the code that follows, and I create an instance:

 e=S()

How do I access the inherited default 'x' in e (inherited from R)?

class R(object):
    def __init__(self):
        self.__x = 0
    def getx(self):
        return self.__x
    def setx(self,x):
        self.__x = x
    x = property(getx,setx)

class S(R):
    def __init__(self):
        self.__y = 0
    def gety(self):
        return self.__y
    def sety(self,y):
        self.__y = y
    y = property(gety,sety)




More information about the Python-list mailing list