DEV Community

Discussion on: Dead Simple Python: Errors

Collapse
 
codemouse92 profile image
Jason C. McDonald • Edited

Okay, so after a bit of discussion in #python on Freenode IRC, we've come to this verdict:

  1. Any time you have an __init__() and you've inherited, call super().__init__(). Period. However...

  2. There are some camps that argue that if you don't otherwise need an __init__() (other than to call super), don't bother with it at all. Others, including myself, believe in always explicitly declaring an initializer with super(). I don't know that there's a clear right or wrong here. They both work out the same.

  3. The weird behavior in your code is because there's a typo...which honestly came from me. You should NOT pass self to super().__init__(self, message)! That should instead read super().__init__(message). (I've fixed that in my article.)

Thanks to altendky, dude-x, _habnabit, TML, and Yhg1s of Freenode IRC's #python for the insight.

Thread Thread
 
rpalo profile image
Ryan Palo

Ooooohkay, gotcha. That makes total sense. Yeah, I think I fall in the camp of not showing the __init__ unless I'm extending it (because I think it looks prettier), but I could see the "explicit is better" argument for the other way.

The most important thing is that you showed me the right way to extend if I need to, which I really appreciate!