Amaury Forgeot d'Arc added the comment:
Well, "Errors should never pass silently."
In this case, it is possible to replace "Person.population" by
"self.__class__.population".
This said, it could be interesting to cleanup modules in a more
predictive way, for example in the reverse order of thei
Mark Dickinson added the comment:
This has to do with the order that things are deleted/cleaned-up on
interpreter shutdown. In the reported case, it just happens that the
'Person' entry in the globals() dict is deleted *before* __del__ is called
on the last Person instance, causing problems
R. David Murray added the comment:
You examples both work for me. Please go to python-list or python-tutor
for help debugging your code. In particular you need to learn more
about __del__ and why you probably don't want to be using it.
rdmur...@maestro:~/python/trunk>./python
Python 2.7a0 (
New submission from tq0fqeu :
To create a instance of Class Person
[code]
rosss = Person('ross')
rosss.sayHi()
rosss.howMany()
[/code]
It's OK
But
[code]
ross = Person('ross')
ross.sayHi()
ross.howMany()
[/code]
It has exception, get that:
Exception AttributeError: "'NoneType' object has no attr