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 __del__(self): print '%s is leaving' % self.name Person.population -= 1 print 'population = %d' %Person.population p = Person('Jean') d = Person('Michael') Output: Jean has been added Michael has been added Michael is leaving population = 1 Jean is leaving *Exception exceptions.AttributeError: "'NoneType' object has no attribute 'population'" in <bound method Person.__del__ of <__main__.Person instance at 0xb7dadacc>> ignored* So once all objects have been destroyed, an exception is triggered on class variable 'population'. Any more logical explanation and work around? I just need to understand what python is doing here Thx Blaise
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor