February 2006
Intermediate to advanced
648 pages
14h 53m
English
A program terminates when no more statements exist to execute in the input program, when an uncaught SystemExit exception is raised (as generated by sys.exit()), or when the interpreter receives a SIGTERM or SIGHUP signal (on UNIX). On exit, the interpreter decrements the reference count of all objects in all the currently known namespaces (and destroys each namespace as well). If the reference count of an object reaches zero, the object is destroyed and its __del__() method is invoked.
It’s important to note that in some cases the __del__() method might not be invoked at program termination. This can occur if circular references exist between objects (in which case objects may be allocated, but accessible from no known namespace). ...