Refactored 'with' statement for comatability with jython.