Advice needed on __del__

Fredrik Lundh fredrik at pythonware.com
Tue May 10 10:42:57 EDT 2005


André Roberge wrote:

> If I need to have the user call Evil.destroy() as Evil
> is getting out of scope, it would miss the whole point
> of teaching about the natural way scope and namespace
> work.

well, if you insist on using finalizers to keep track of what's in the current
scope, I'd say that you are missing the point about how scopes and name-
spaces work...

(to track the contents of a scope, you have to look at the scope.)

> A thought occurred to me, regarding "when" __del__
> is called.  Can I force Python, through some function call,
> to perform this.  Each time I refresh the screen, I could
> force that call, then check to see if Evil has been
> destroyed by Python, which would give me the information
> I need to destroy Evil_twin behind the scene myself -
> which is what I am really after.

the correct solution is to inspect the current namespace every time you
refresh the screen, and make sure the screen contents matches what's
in the namespace.

</F> 






More information about the Python-list mailing list