Skip to content

Commit 55a8bf2

Browse files
committed
2016/4/17
ex42_class.py
1 parent cbf3a35 commit 55a8bf2

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

lihoufeng/ex42_class.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
class TheThing(object):
2+
3+
def __init__(self):
4+
self.number = 0
5+
6+
def some_function(self):
7+
print "I got called."
8+
9+
def add_me_up(self, more):
10+
self.number += more
11+
return self.number
12+
13+
a = TheThing()
14+
b = TheThing()
15+
16+
a.some_function()
17+
b.some_function()
18+
19+
print a.add_me_up(20)
20+
print a.add_me_up(20)
21+
print b.add_me_up(30)
22+
print b.add_me_up(30)
23+
24+
print a.number
25+
print b.number

0 commit comments

Comments
 (0)