Created
December 28, 2013 07:44
-
-
Save b7w/8157067 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
class Foo(object): | |
def __init__(self, arg): | |
self.arg = arg | |
def __repr__(self): | |
return 'Foo({})'.format(self.arg) | |
class Bar(object): | |
def __init__(self, arg): | |
self.arg = arg | |
def __repr__(self): | |
return 'Bar({})'.format(self.arg) | |
foo = Foo(1) | |
bar1 = Bar(foo) | |
bar2 = Bar(foo) | |
print(bar1, bar2) # Bar(Foo(1)), Bar(Foo(1)) | |
bar1.arg.arg = 2 | |
print(bar1, bar2) # Bar(Foo(2)), Bar(Foo(2)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment