Inheritance/Late Private Binding

Jeremy Moles jeremy at
Thu Jul 7 02:23:55 CEST 2005

class BaseClass:
        def __init__(self):
                self.__data = None

        def getMember(self):
                return self.__data

class GoodSubClass(BaseClass):
        def __init__(self):

class BadSubClass(BaseClass):
        def __init__(self):
                self.__x = None

gsc = GoodSubClass()
print dir(gsc)

bsc = BadSubClass()
print dir(bsc)


Forgive me if this topic has been brought up before, but I was curious
as to why I was getting this behavior and was hoping someone
knowledgeable could explain. :)

I "feel" like even without the explicit call to a simple base ctor(),
mangling should still happen correctly. This doesnt, however, seem to be
the case...

Of note: simply doing a 'pass' in BadSubClass seems to be sufficient as
well; so, it has something to do with defining a ctor() in the child and
not explicitly invoking the parent's ctor.

More information about the Python-list mailing list