execfile question

Kerim Borchaev warkid at storm.ru
Tue Feb 19 08:23:19 EST 2002


Mark Barclay answered:

> "del c" will cause your __del__() to be called.
yes

> So will any other action that causes your instance to be garbage-collected.
I don't get it.
And can you explain who holds a reference on C instance in my example
when 'execfile' completes?

Kerim.

----------------------------------
My original question:

> 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.






More information about the Python-list mailing list