Classes, virtual methods ?

Scott David Daniels scott.daniels at acm.org
Fri May 16 14:01:10 EDT 2003


Rony wrote:
> ...Is there a way of calling foo of the master class of B
 > with an instance of B...

Perhaps you meant something like this (2.2.2 and 2.3 do it):

class A(object):
    def foo(self):
        print "in class A"

class B(A):
    def foo(self):
        print "in class B"
        super(B, self).foo()

m = B()
m.foo()

Scott David Daniels
Scott.Daniels at Acm.Org





More information about the Python-list mailing list