Created
June 20, 2020 01:36
-
-
Save amaurs/c7ff41c9d51366dcda3fe859395a15db 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 A: | |
def __init__(self): | |
self.some_value = {} | |
class B(A): | |
def modify_value(self): | |
self.some_value.update({"some_value": "b"}) | |
class C(A): | |
def modify_value(self): | |
self.some_value.update({"some_value": "c"}) | |
if __name__ == '__main__': | |
b = B() | |
c = C() | |
c.modify_value() | |
print(b.some_value) | |
b.modify_value() | |
print(b.some_value) | |
c.modify_value() | |
print(c.some_value) | |
# {} | |
# {'some_value': 'b'} | |
# {'some_value': 'c'} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment