language: Python 3 (python-3.2.3)
date: 186 days 3 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
class Pipe:
    state = True
    def draw(self):
        print("I am a pipe.")
        if(self.state):
            print("I am enabled.")
        else:
            print("I am disabled.")
 
 
class FastPipe(Pipe):
    speed = 1.0
    def draw(self):
        Pipe.draw(self)
        print("I transport things quickly.")
        print("My speed is", self.speed)
 
 
pipe = Pipe()
pipe.state = False
pipe.draw()
print("")
pipe.__class__ = FastPipe
pipe.speed += 0.5
pipe.draw()