Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?
Ethan Furman
ethan at stoneleaf.us
Mon Jul 26 12:20:06 EDT 2010
Gregory Ewing wrote:
> Raymond Hettinger wrote:
>> Every class
>> in the MRO implementing the target method *must* call super() to give
>> the next class in the MRO a chance to run.
>
> EXCEPT for the last one, which must NOT call super!
>
> The posted example happens to work because object has
> a default __init__ method that does nothing. But this
> is not generally true of other methods, which means you
> need a "terminating" class at the end of the MRO whose
> methods don't call super.
Speaking of new-style classes only, don't they all end in object? And
if the MRO is only known at run-time, how is one to know at code-time
whether your (new-style) class is at the end of the line?
~Ethan~
More information about the Python-list
mailing list