On Wed, Jan 7, 2009 at 2:39 PM, Eric Snow <es...@verio.net> wrote: > I was reading in the documentation about __del__ and have a couple of > questions. Here is what I was looking at: > > http://docs.python.org/reference/datamodel.html#object.__del__ > > What is globals referring to in the following text from that reference > page? > > "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.
Names with a *single* leading underscore are, by convention, "private". Names with double leading and trailing underscores are for special methods. The sort-of private methods are the ones that get deleted first, not the special methods. > > -- > http://mail.python.org/mailman/listinfo/python-list >
-- http://mail.python.org/mailman/listinfo/python-list