execfile question
Bengt Richter
bokr at oz.net
Tue Feb 19 22:42:08 EST 2002
More information about the Python-list mailing list
Tue Feb 19 22:42:08 EST 2002
- Previous message (by thread): execfile question
- Next message (by thread): execfile question
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tue, 19 Feb 2002 16:23:19 +0300, Kerim Borchaev <warkid at storm.ru> wrote: >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? > I suspect the anonymous directory you passed to execfile. Apparently dictionaries don't always get cleared automatically. I don't know if this is a bug. But if you do: xdict = {} execfile('executable.py', xdict) xdict.clear() # just del xdict doesn't do it I think your example will give you what you expected. Using default dicts like this: execfile('executable.py') works too. Regards, Bengt Richter >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. > > >
- Previous message (by thread): execfile question
- Next message (by thread): execfile question
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list