Privacy and Inheritance

Dennis B. dcswest at flashmail.com
Wed Sep 4 00:01:41 EDT 2002


Greetings; 

Have enough confidence in Python to realize this is probably just my
misunderstanding, but wondering why Python mangles private, double
underscore attributes with the name of the base class even if they're
inherited and the instance is that of the sub class. 

Like the following doesn't even seem to work: 

class StandardNormal: 

    def letEventZScore(self, eventZScore): 
        self.__eventZScore = float(eventZScore) 

class DerivativeNormal(StandardNormal): 

    def getCentral(self): 
        if self.__eventZScore < 0: 

Unless I change that last line to something like: 

        if self._StandardNormal__eventZScore < 0: 

Maybe just missing the point all together, but wondering if anyone'll
point out anything a little more elegant and/or intuitive. 

Thank you and have a great day,





More information about the Python-list mailing list