Problem with __del__
Stephan Effelsberg
b012414 at mail.dvz.fh-koeln.de
Tue Jan 9 14:19:16 EST 2001
I have the following code:
def dosomething():
print "doing something"
class Nothing:
def __init__(self, name):
self.name=name
def __del__(self):
print self.name, dosomething
dosomething()
cl=Nothing("cl")
nothing=Nothing("nothing")
cla=Nothing("cla")
cl2=Nothing("cl2")
When running this (Python 1.5.2 on Win95) I get the following output:
cl2 <function dosomething at 8a7c90>
doing something
cla <function dosomething at 8a7c90>
doing something
cl <function dosomething at 8a7c90>
doing something
nothing None
Exception exceptions.TypeError: 'call of non-function (type None)' in
<method Nothing.__del__ of Nothing instance at 8a7f60> ignored
Everything works properly except for 'nothing'.
Now I swapped the lines for instanciating 'cl' and 'nothing' with the
following result:
cl2 <function dosomething at 8a7c90>
doing something
cla <function dosomething at 8a7c90>
doing something
nothing None
Exception exceptions.TypeError: 'call of non-function (type None)' in
<method Nothing.__del__ of Nothing instance at 8a7ee0> ignored
cl None
Exception exceptions.TypeError: 'call of non-function (type None)' in
<method Nothing.__del__ of Nothing instance at 8a7f60> ignored
Now it seems that both 'nothing' and 'cl' aren't able to see the
function dosomething().
Can somebody explain this phenomenon?
Is it a special bug of my specific Python distribution?
More information about the Python-list
mailing list