del method example 3

This commit is contained in:
Mert Gör ☭ 2023-07-26 13:19:03 +03:00
parent 6a0009cbf5
commit 291d7ef8d4
No known key found for this signature in database
GPG Key ID: 2100A876D55B39B9
2 changed files with 90 additions and 0 deletions

View File

@ -0,0 +1,47 @@
class A:
def __init__(self):
super().__init__()
print('A.__init__ called')
def __del__(self):
print('A.__del__ called')
super().__del__()
class B:
def __init__(self):
super().__init__()
print('B.__init__ called')
def __del__(self):
print('B.__del__ called')
class C(A):
def __init__(self):
super().__init__()
print('C.__init__ called')
def __del__(self):
print('C.__del__ called')
super().__del__()
class D(B):
def __init__(self):
super().__init__()
print('D.__init__ called')
def __del__(self):
print('D.__del__ called')
super().__del__()
class E(C, D):
def __init__(self):
super().__init__()
print('E.__init__ called')
def __del__(self):
print('E.__del__ called')
super().__del__()
e = E()
e = None
print(E.__mro__)

View File

@ -0,0 +1,43 @@
class A:
def __init__(self):
super().__init__()
print('A.__init__ called')
def __del__(self):
print('A.__del__ called')
super().__del__()
class B:
def __init__(self):
super().__init__()
print('B.__init__ called')
def __del__(self):
print('B.__del__ called')
class C(A):
def __init__(self):
super().__init__()
print('C.__init__ called')
def __del__(self):
print('C.__del__ called')
super().__del__()
class D(B):
def __init__(self):
super().__init__()
print('D.__init__ called')
def __del__(self):
print('D.__del__ called')
super().__del__()
class E(C, D):
def __init__(self):
super().__init__()
print('E.__init__ called')
def __del__(self):
print('E.__del__ called')
super().__del__()