Builtn super() function. How to use it with multiple inheritance? And why should I use it at all?
Gregory Ewing
greg.ewing at canterbury.ac.nz
Sun Jul 25 20:30:08 EDT 2010
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.
--
Greg
More information about the Python-list
mailing list