subclass constructor problem

Diez B. Roggisch deets at
Tue Oct 5 17:52:31 CEST 2010

Nikola Skoric <nick at> writes:

> I have a superclass Element and a subclass Family. All Family.__init__() does is run Element.__init__() and self.__parse(). For some reason it seems like self.__parse() isn't run. Here is the code:
> In this version everything works fine. Notice lines 698, 703 and 708. If I remove those lines, those 3 methods return None or []. Seems like __init__ won't run __parse, but other methods run it without problem.
> So, what obvious thing am I missing? :-)

Works without a hitch for my condensed example:

class Element(object):

    def __init__(self):

class Family(Element):

    def __init__(self):

    def __parse(self):
        self.parse = "Family.__parse"

f = Family()
print f.parse

Btw, you are a bit on the overprotective side. The convention for
marking attributes (methods or objects alike) "private" is by prefixing
them with a *single* underscore. 


More information about the Python-list mailing list