Skip to content

Instantly share code, notes, and snippets.

@chaliy chaliy/fooker1.py
Last active Aug 29, 2015

Embed
What would you like to do?
# What output you expect form this?
class Fooker(object):
def __init__(self, items = []):
self.items = items
def append(self, item):
self.items.append(item)
o = Fooker()
o.append("1234")
print(o.items)
o1 = Fooker()
o1.append("1234")
print(o1.items)
@alexbeletsky

This comment has been minimized.

Copy link

alexbeletsky commented May 10, 2014

› python s.py
['1234']
['1234', '1234']

but it's really strange to me... Why?

@chaliy

This comment has been minimized.

@alexbeletsky

This comment has been minimized.

Copy link

alexbeletsky commented May 10, 2014

Good to know, but seems too un-obvious to me..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.