del method example 4

This commit is contained in:
Mert Gör 🇹🇷 2023-07-26 13:23:38 +03:00
parent 291d7ef8d4
commit a10503c12d
No known key found for this signature in database
GPG key ID: 2100A876D55B39B9

View file

@ -0,0 +1,18 @@
class Sample:
def __init__(self, x):
self.x = x
print('Sample.__init__ called: {}'.format(x))
def __del__(self):
print('Sample.__del__ called: {}'.format(self.x))
a = Sample(10)
b = Sample(20)
def foo():
x = Sample(30)
y = Sample(40)
print('first')
foo()
print('second')