python - Overriding a parent class's methods -


Something I see people all the time:

  class man (object) : Def say_hi (self): print ('hello, world.') Class stimulating man (man): def say_hi (self): print ('wow!') Super (exciting, self) .sai_hi () # parent Calling the version once done with custom stuff  

Something I'm never looking for:

  class man (object): def sayshihi (Self): print ('hello, world.') Ahi Man (Man): DEP says (self): print ( "Wow!") Return (super exciting, self). Sai_hi () # Returning the value of the call, so that parents can complete the contract of class  

Is it that I am hanging with all the wrong programmers, or is it any good For the reason?

I argue that the return value of the super class method is returning clearly and would be more prudent (Only in rare cases where the child wants to stop it). Especially when you do not know what Super Super is doing, in Python you can usually see the super class method and find out what it does, but still.

Of course, those who wrote in another edition, they themselves know the parent class and / or that it has no return value. In that situation, they decided to make a statement without a clear and clear return.


Comments