One Worry for 2.2

Mitch Chapman chapman at
Wed Jul 18 20:05:49 CEST 2001

Pete Shinners wrote:
> i'm excited for the new features coming in 2.2. reading some
> release notes, i found a new difference that bothers me.
> """
> There's one very specific (and fortunately uncommon) bug that
> used to go undetected, but which is now reported as an error:
>     class A:
>         def foo(self): pass
>     class B(A): pass
>     class C(A):
>         def foo(self):
> Here, wants to call, but by mistake calls
> In the old system, because B doesn't define foo, is
> identical to, so the call would succeed. In the new
> system, is marked as a method requiring a B instance,
> and a C is not a B, so the call fails.
> """
> now in my mind's understanding of OO, if class B inherits
> from class A, then class B has a foo() function. what this
> is implying is that only _instances_ of class B have a foo()
> function.

B does have a foo method.  The problem is that C is derived 
from A, not from B.  So an instance of C shouldn't be 
allowed to pass itself to

Who is sometimes able to pass himself off as a programmer,
even though he isn't descended from one.

More information about the Python-list mailing list