[Tutor] Python Gotcha - List Question
Guess?!?
wtfwhoami at gmail.com
Tue Jun 17 07:10:12 CEST 2008
Hello All,
Just made a minor change ..... its fixed now :)
class Kangaroo:
def __init__(self, pouch_contents=None):
if pouch_contents is None:
self.pouch_contents = []
else:
self.pouch_contents = pouch_contents
def put_in_pouch(self,obj):
self.pouch_contents.append(obj)
return self.pouch_contents
kanga = Kangaroo()
roo = Kangaroo()
print kanga,roo
print kanga.put_in_pouch(roo.pouch_contents)
***********************************************************************88
<__main__.Kangaroo instance at 0x00A9A878> <__main__.Kangaroo instance
at 0x00A9A8A0>
[[]]
More information about the Tutor
mailing list