[Tutor] Object Destruction
Wed, 24 Jan 2001 23:01:19 -0800 (PST)
> Try some more experiments with __del__. I'm somewhat bothered by what
> happened at the beginning of the interpreter session above, and might take
> a look again later to figure out why it didn't garbage collect initially.
Ah! Now I know why! There's still a reference!
>From the Python tutorial:
"In interactive mode, the last printed expression is assigned to the
Tricky little critter! In the situation here:
<__main__.TestDel instance at 0x81ca2fc>
the reason that it didn't garbage collect immediately was because the
interactive interpreter itself has a reference to the instance with the
"_" variable. Since there's still a reference, it doesn't die until "_"
is reassigned to the next evaluated expression or statement.
Ok, that nagging feeling is gone now. *grin*