The Final Word on __init__() in Subclassing

Following up on my previous post–“Multiple Constructors while Subclassing“–I found that the original problem presented there is, nowadays, common knowledge among Python users. Around the ‘Net, the same sentiment is bemoaned:

Notice that in the derived classes, we explicitly call the __init__ method of the base class so that the superclass portion of the object can be initialized. This is very important to remember – Python does not automatically call the constructor of the base class, you have to explicitly call it yourself.


While this admittedly sucks ass, it’s got to be done or you’ll never get shit to work as expected.

Upshot: The code under “Update 2” in my previous post is, in fact, exactly how you must do it.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s