> It sounds like you'll want to clean up Foo, no matter what, when your > program finishes. If so, you'll want to look at the atexit module: > > http://python.org/doc/current/lib/module-atexit.html > > I have to admit: I've never touched this beast before, but it sounds > exactly like what you want. > can I back port this to 1.5? This code is not 2.x dependant.