3 ms·
To implement scope guard you can use with statement and implement __enter__, __exit__ methods. It is not real RAII as object is not destroyed on exit but it is
by kubav 6y ago
To implement scope guard you can use with statement and implement __enter__, __exit__ methods. It is not real RAII as object is not destroyed on exit but it is still quite useful.
http://effbot.org/zone/python-with-statement.htm http://effbot.org/zone/python-with-statement.htm