Created
March 30, 2011 02:04
-
-
Save agrif/893734 to your computer and use it in GitHub Desktop.
wacky python bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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