Skip to content

Instantly share code, notes, and snippets.

@chaliy
Last active August 29, 2015 14:01
Show Gist options
  • Save chaliy/aca75eb7055ee2f553fa to your computer and use it in GitHub Desktop.
Save chaliy/aca75eb7055ee2f553fa to your computer and use it in GitHub Desktop.
# 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
Copy link

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

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

@chaliy
Copy link
Author

chaliy commented May 10, 2014

@alexbeletsky
Copy link

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