execfile question
Mark Barclay
markabarclay at attbi.com
Tue Feb 19 07:51:10 EST 2002
"del c" will cause your __del__() to be called.
So will any other action that causes your instance to be garbage-collected.
For example, try:
>>> class D:
... def __init__(self):
... self.myC = C()
...
>>> d = D()
init
>>> del d
deleted
>>>
Kerim Borchaev wrote:
> Can someone explain why while running this script I don't see C.__del__
> eventually called?
>
> For me the output of it's execution is:
>
> >main.py
> it's me
> init
> executed
> >
>
> ##main.py######################
> execfile('executable.py', {})
> print 'executed'
> ########################
>
> ##executable.py######################
> print "it's me"
> class C:
> def __init__(self):
> print 'init'
> def __del__(self):
> print 'deleted'
>
> c = C()
> ########################
>
> Thanks in advance.
--
Mark Barclay (markabarclay at attbi.com)
More information about the Python-list
mailing list