del behavior

Eric Snow esnow at
Wed Jan 7 20:39:13 CET 2009

I was reading in the documentation about __del__ and have a couple of
questions.  Here is what I was looking at:

What is globals referring to in the following text from that reference

"Starting with version 1.5, Python guarantees that globals whose name
begins with a single underscore are deleted from their module before
other globals are deleted; if no other references to such globals
exist, this may help in assuring that imported modules are still
available at the time when the __del__() method is called."

Thus those with an _ get deleted before everything else.  This is not
referring to members of my objects is it, such that those members
starting with _ get deleted first?  I suppose that would delete
__del__ before it would get called so I assume that is not the case.
But I want to be sure about that behavior and exactly what globals
is.  Is globals meaning the contents of "globals" or something else.
I ask because sometimes some words get used for varied meanings.

More information about the Python-list mailing list