The final release of python 2.5 is out! The list of what’s new is pretty impressive, but I’m especially happy to have the new “with” statement. Ruby has block methods, or closures, which can be used for doing very clean setup/cleanup. While full-blown Anonymous block statements were rejected from Python, the new “with” statement handles the part I care about: making it easier to write code that works correctly in the case of failures.
The 3 typical use cases are a file that needs to be closed, a lock that needs to be released, and and a database transaction that needs to be either committed or rolled back. The database case is the …
[Read more]