Skip to content

Instantly share code, notes, and snippets.

@cameronwlewis
Created June 26, 2019 01:16
Show Gist options
  • Save cameronwlewis/384730d9d5244226de3b9d7d30372712 to your computer and use it in GitHub Desktop.
Save cameronwlewis/384730d9d5244226de3b9d7d30372712 to your computer and use it in GitHub Desktop.
class FirstClass:
def __init__(self, value):
self.value = value
class SecondClass:
def __init__(self):
self.a = 'a'
self.b = FirstClass('b')
def confuse_me(self):
# After changing c, self.a doesn't change.
c = self.a
c = 'c'
print('\nself.a is: \n' + str(self.a))
# After changing e, self.b changes.
e = self.b
e.value = 'e'
print('\nb is: \n' + str(self.b.value))
if __name__ == '__main__':
t = SecondClass()
t.confuse_me()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment