The PEP343 documentation contains details regarding the 'with' keyword, but to put it in simple words
when the code ends the with keyword will clean up the resource that the code used, despite of exceptions. when using with keyword the try/finally blocks can be carefully avoided.
Python with statement simplifies exception handling in Python,