Re: [Tutor] __del__ exception

2008-06-05 Thread Alan Gauld
"Blaise Morose" <[EMAIL PROTECTED]> wrote I have this silly piece of code that I am experimenting with: I'm not certain but... based on this quote from the Python docs: -- Warning: Due to the precarious circumstances under which __del__() methods are invoked, exceptions that occur during

Re: [Tutor] __del__ exception

2008-06-05 Thread Michael Langford
There is no remaining referent to your class at the point when the last instance has started to be deleted. This allows the class itself to be garbage collected. Changing the code to the following will prevent this. #!/usr/bin/python class Person: population = 0 def __init__(self

Re: [Tutor] __del__ exception

2008-06-05 Thread wesley chun
> class Person: > population = 0 > > def __init__(self, name): > self.name = name > print '%s has been added' %self.name > Person.population += 1 > > def __del__(self): > print '%s is leaving' % self.name >

[Tutor] __del__ exception

2008-06-05 Thread Blaise Morose
Hi, I have this silly piece of code that I am experimenting with: #!/usr/bin/python class Person: population = 0 def __init__(self, name): self.name = name print '%s has been added' %self.name Person.population += 1 def _