-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathex41.py
44 lines (29 loc) · 793 Bytes
/
ex41.py
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
class TheThing(object):
"""docstring for TheThing"""
def __init__(self):
self.number = 0
def some_function(self):
print "I got called."
def add_me_up(self,more):
self.number += more
return self.number
#two different things
a = TheThing()
b = TheThing()
a.some_function()
b.some_function()
print a.add_me_up(20)
print b.add_me_up(30)
print a.number
print b.number
# Study this. This is how you pass a variable
#from one class to another. You will need this
class TheMultiplier(object):
"""docstring for TheMUltiplier"""
def __init__(self, base):
super(TheMultiplier, self).__init__()
self.base = base
def do_it(self, m):
return m * self.base
x = TheMultiplier(a.number)
print x.do_it(b.number)