File: class/Workbook/Examples/Lecture7/extending.py

>>> class Super:
...     def method(self):
...         print 'in Super.method'
... 
>>> class Sub(Super):
...     def method(self):
...         print 'starting Sub.method'
...         Super.method(self)
...         print 'ending Sub.method'
... 

>>> x = Super()
>>> x.method()
in Super.method

>>> x = Sub()
>>> x.method()
starting Sub.method
in Super.method
ending Sub.method



[Home page] Books Code Blog Python Author Train Find ©M.Lutz