del method example 2

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

View File

@ -0,0 +1,19 @@
class A:
def __init__(self):
print('A.__init__ called')
def __del__(self):
print('A.__del__ called')
class B(A):
def __init__(self):
super().__init__()
print('B.__init__ called')
def __del__(self):
print('B.__del__ called')
super().__del__()
b = B()
b = None

View File

@ -0,0 +1,12 @@
class A:
def __init__(self):
print('A.__init__called')
def __del__(self):
print('A.__del__called')
class B(A):
def __init__(self):
super().__init__()
print('B.__init__called')