An alternative approach to bound methods

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Thu Feb 22 09:38:53 EST 2001


Thu, 22 Feb 2001 11:14:05 +0100, Alex Martelli <aleaxit at yahoo.com> pisze:

> I *STRONGLY* disagree, because in the third case, AND IN IT ONLY,
> inheritance and overriding come into play!!!

Sure. So depending on whether you want recursive call to refer to
the function itself or to its version overridden by inheritance,
you would write either
    foo
    X.foo
or
    self.__class__.foo
    self.foo # After initialization of self.foo in __init__

> _Normally_ the potential for polymorphism and overriding IS desired,

In recursive calls to class methods? Not at all. If the overridden
version calls me, it probably expects that I would do what I was
supposed to do in the superclass. No matter if I do this by calling
myself recursively or not.

Not to say that class methods would rarely be overridden at all -
they are not called in the context of an instance after all.

Remember that I am talking about class methods, which don't exist
now at all. They can be currently expressed as module functions which
are not subject to inheritance. Instance methods are normally called
through self as always!

-- 
 __("<  Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
 \__/
  ^^                      SYGNATURA ZASTĘPCZA
QRCZAK



More information about the Python-list mailing list