Skip to content

Instantly share code, notes, and snippets.

@amaurs
Last active June 20, 2020 01:37
Show Gist options
  • Save amaurs/e7ad7f8dbf6edd74fd990485b8ebcc0f to your computer and use it in GitHub Desktop.
Save amaurs/e7ad7f8dbf6edd74fd990485b8ebcc0f to your computer and use it in GitHub Desktop.
exhibit a
class A:
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': 'c'}
# {'some_value': 'b'}
# {'some_value': 'c'}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment