Before clicking the link I wondered how this would translate the block-based Ruby API into Python. Using Python's with statement is quite nice here, I think.<p>The with statement is one of my favorite additions to the language. It's a really flexible syntax to encapsulate control flow, exceptions, necessary cleanup steps… etc. etc.