Calling baseclass method from a derivated class (others will probably give you a better solution)
Mike Carifio
carifio.nospam at nospam.usys.com
Tue Feb 26 10:00:04 EST 2002
class Base:
def meth(self):
print "Base.meth"
class Derived (Base):
def meth(self):
print "Derived.meth"
# Embeds knowledge of superclass in method implementation.
def chain(self):
Base.meth(self)
b = Base()
# Find b's meth, Base.meth.
b.meth()
d = Derived()
# Find d's meth, Derived.meth
d.meth()
# Find d's chain, which in turn calls Base.meth.
d.chain()
# Call Base.meth directly.
# Probably a more object-oriented way...
Base.meth(d)
More information about the Python-list
mailing list