Skip to content

Instantly share code, notes, and snippets.

@agrif
Created March 30, 2011 02:04
Show Gist options
  • Save agrif/893734 to your computer and use it in GitHub Desktop.
Save agrif/893734 to your computer and use it in GitHub Desktop.
wacky python bug
class SomeClass:
def __init__(self, some_var=[]):
self.data = some_var
def append(self, var):
self.data.append(var)
a = SomeClass()
a.append(1)
a.append(2)
print a.data
# [1, 2]
b = SomeClass()
print b.data
# [1, 2]
# freaky, huh?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment