del method example 4
This commit is contained in:
parent
291d7ef8d4
commit
a10503c12d
1 changed files with 18 additions and 0 deletions
18
python-temel/del.method.4.py
Normal file
18
python-temel/del.method.4.py
Normal 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')
|
Loading…
Reference in a new issue