PyDocs

Nav

Python Runtime Services

closing

contextlib

function (source)
  • closing(thing)
Context to automatically close something at the end of a block.

Code like this:

    with closing(<module>.open(<arguments>)) as f:
        <block>

is equivalent to this:

    f = <module>.open(<arguments>)
    try:
        <block>
    finally:
        f.close()
0 Examples
No examples for contextlib/closing.
See Also
No see-alsos for contextlib/closing
0 Notes
No notes for closing