Is it possible to create an object in Python that will clean itself up at function exit? I realize destruction of objects may not occur immediately and can be garbage collected, but this functionality would still be great to have. Consider the following function:
def do_stuff(): foo = scope_object() # Do stuff... foo.Cleanup() It would be nice to avoid the explicit "Cleanup()" call above, and have 'foo' just act as if it has a C++ destructor and evoke some method at the exit point of a function. -- http://mail.python.org/mailman/listinfo/python-list