total idiot question: +=, .=, etc...

Greg Ewing greg.ewing at compaq.com
Thu Jul 1 17:05:46 EDT 1999


Guido van Rossum wrote:
> 
> Oh, but that check *is* being made!

No, it's not. The check I'm talking about would
cause the call to A.foo in class C below to
fail. (And it doesn't -- I've just tried it.)

class A:
    def foo(self):
        print "foo of A"
        
class B(A):
    def foo(self):
        print "foo of B"
        A.foo(self)
        
class C(B):
    """Fred Coder originally wrote this
    so it was C(A), then changed it and
    forgot to update the method."""
    def foo(self):
        print "foo of C"
        A.foo(self)

c = C()
c.foo()

Do you see what I mean now?
Greg




More information about the Python-list mailing list