Module inh_example
[hide private]
[frames] | no frames]

Source Code for Module inh_example

 1  # 
 2  # inh_example.py 
 3  # 
 4  # Example code used by the epytext manual. 
 5  # 
 6  # These classes are used to illustrate the different inheritance 
 7  # styles. (grouped, listed, and included). 
 8  # 
 9  """ 
10  Examples for the epytext manual. 
11  """ 
12  __docformat__='epytext' 
13   
14 -class Animal:
15 - def eat(self, food): "Consume the given food object."
16 - def sleep(self, time): "Sleep for the given period of time."
17
18 -class Bug(Animal):
19 - def infest(self, code): "Add new bugs to the given program."
20 - def hide(self):
21 """ 22 Temporarily stop breaking a program, in order to evade 23 capture. 24 """
25 -class Bird(Animal):
26 - def fly(self, dest): "Fly to the given destination."
27
28 -class Fish(Animal):
29 - def swim(self, dest): "Swim to the given destination."
30
31 -class Mammal(Animal):
32 - def run(self, dest): "Run to the given destination."
33
34 -class Primate(Mammal):
35 - def climb(self, tree): "Climb up the given tree."
36 - def grab(self, object): "Grab hold of the given object."
37
38 -class Human(Primate):
39 - def talk(self, animal):
40 """ 41 Talk to the given animal. Depending on what kind of creature 42 C{animal} is, it may or may not be responsive. 43 """
44
45 -class Programmer(Human):
46 - def hack(self, code): "Improve the given program."
47 - def squish(self, bug, code):
48 """ 49 Remove the given bug from the given program. 50 @type bug: L{Bug} 51 @param bug: The bug that should be removed from C{code}. 52 """
53