Hi Jach,
On 20/10/2019 09:34, jf...@ms4.hinet.net wrote:
What puzzles me is how a parent's method foo() can find its child's method
goo(), no matter it was overwrote or not? MRO won't explain this and I can't
find document about it also:-(
This is a generalised description - Python may be slightly different.
When foo invokes goo the search for goo starts at the class of the
object (which is B), not the class of the executing method (i.e not A).
It then proceeds to look for goo up the class hierarchy - first in B,
then A then Object.
If that fails the RTS modifies the call, to look for a magic method, and
starts again at B. When the magic method is found in Object, you get the
"not found" error. If you implement the magic method in A or B it will
be run instead.
Regards
Ian
--
This email has been checked for viruses by AVG.
https://www.avg.com
--
https://mail.python.org/mailman/listinfo/python-list