title: What is the Python "with" statement used for?
body: <p>I am trying to understand the with statement in python.  Everywhere I look it talks of opening and closing a file, and is meant to replace the try-finally block. Could someone post some other examples too.  I am just trying out flask and there are with statements galore in it.  Definitely request someone to provide some clarity on it.</p>