Is RAII possible in Python?
Paul Rubin
http
Sat Nov 15 17:03:19 EST 2003
Pierre Rouleau <prouleau at impathnetworks.com> writes:
> AFAIK, the call of __del__() method on object destruction is not
> garanteed to be called when the interpreter exists. Is this true?
I think it is supposed to be called.
> Is the __del__() mehod of an object garanteed to be called when a
> function exists normally or is forced to exit by an exception?
No.
> Is RAII available in Python?
You can use the try/finally construction to make sure the object gets
destroyed when the finally clause runs.
More information about the Python-list
mailing list