inheritance
Sean Ross
frobozz_electric at hotmail.com
Thu Jun 12 12:06:10 EDT 2003
For example:
class Base:
def __init__(self, value):
self.value = value
def __mul__(self, other):
return self.__class__(self.value * other.value)
class Child(Base):
def __init__(self, value):
Base.__init__(self, value)
x = Base(2)
y = Base(3)
z = Child(4)
w = Child(5)
print x*y
print z*w
"""OUTPUT
<__main__.Base instance at 0x009991E0>
<__main__.Child instance at 0x009991E0>
"""
More information about the Python-list
mailing list