-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path17.4.py
More file actions
29 lines (21 loc) · 718 Bytes
/
Copy path17.4.py
File metadata and controls
29 lines (21 loc) · 718 Bytes
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
#coding:utf-8
class Kangaroo(object):
def __init__(self,pouch_contents=[]):
self.pouch_contents = pouch_contents
def put_in_pouch(self,obj):
self.pouch_contents.append(obj)
def __str__(self):
t = [object.__str__(self) + ' with pouch contents:']
for obj in self.pouch_contents:
s = ' ' + object.__str__(obj)
t.append(s)
return '\n'.join(t)
kanga = Kangaroo()
roo = Kangaroo()
kanga.put_in_pouch('wallet')
kanga.put_in_pouch('cookies')
kanga.put_in_pouch(roo)
print kanga
print roo
print kanga.pouch_contents is roo.pouch_contents
print kanga.pouch_contents == roo.pouch_contents