Skip to content

Instantly share code, notes, and snippets.

@b7w
Created December 28, 2013 07:44
Show Gist options
  • Save b7w/8157067 to your computer and use it in GitHub Desktop.
Save b7w/8157067 to your computer and use it in GitHub Desktop.
#!/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