forked from lugnitdgp/Learn-Python
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsampleclass.py
More file actions
Latest commit
23 lines (20 loc) · 451 Bytes
/
Copy pathsampleclass.py
File metadata and controls
23 lines (20 loc) · 451 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# SAMPLE CODE TO ILLUSTRATE CLASSES IN PYTHON
classTheThing(object):
def__init__(self):
self.number=0
defsome_function(self):
print"I got called."
defadd_me_up(self, more):
self.number+=more
returnself.number
# two different things
a=TheThing()
b=TheThing()
a.some_function()
b.some_function()
printa.add_me_up(20)
printa.add_me_up(20)
printb.add_me_up(30)
printb.add_me_up(30)
printa.number
printb.number