Created
June 26, 2019 01:16
-
-
Save cameronwlewis/384730d9d5244226de3b9d7d30372712 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
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