Skip to content

Instantly share code, notes, and snippets.

@podhmo
Created February 10, 2024 06:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save podhmo/b3be44a1950a366048e341ece9c481cd to your computer and use it in GitHub Desktop.
Save podhmo/b3be44a1950a366048e341ece9c481cd to your computer and use it in GitHub Desktop.
class A:
def __init__(self):
self.__c = 1
def a(self):
self.__c += 1
def show(self):
print(f"{self=} a.c is {self.__c=}")
class B(A):
def __init__(self):
super().__init__()
self.__c = 10
def b(self):
self.__c += 10
def show(self):
super().show()
print(f"{self=} b.c is {self.__c=}")
b = B()
b.show()
b.b()
b.b()
b.a()
print()
b.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment