Re: super(...).__init__() vs Base.__init__(self)



Kent Johnson wrote:
Are there any best practice guidelines for when to use
super(Class, self).__init__()
vs
Base.__init__(self)
to call a base class __init__()?

[snip]
>
3. A third fix might be to change both Base and threading.Thread() to call super(...).__init__(). This might break existing code that is written in the style of fix 1 (calling both base class __init__() methods explicitly).

Personally, I'd call the lack of the super calls in threading.Thread and Base bugs. So code relying on that behavior needs to be fixed when the bug is fixed. But __init__() is definitely a tricky case since the number of arguments tends to change in the __init__() methods of classes...

STeVe
.



Relevant Pages

  • Re: Some thoughts about OO programming
    ... type code which is exactly what polymorphism is supposed to help fix. ... in general that's called the fragile base class problem. ... interface IAnimal2: public IAnimal ... reasons to avoid it, many of which you address in your post. ...
    (comp.programming)
  • Re: delete this
    ... static flag member of the class which is cleared just before calling the ... base class CDialog::PostNcDestroyand set by the derived destructor. ... void CDgSplashPanel::PostNcDestroy ...
    (microsoft.public.vc.language)
  • Re: ComboBox Behavior in DropDownList
    ... You may also try to override it's "OnKeyPress" member, and set it to true before calling the base class' procedure. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Distinguishing between one instance object to another instance
    ... You could add a property to your base class, ... > Yess, thats true, BUT for me it is the same as calling ... > while calling a function is less intuitive... ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Storing records from a parsed file
    ... don't see why I can get away with calling it without reference to a ... base class - for a start how does it know whivh one to call... ...
    (comp.lang.python)