contextlib.closing
¶
-
class
contextlib.
closing
(thing)[source]¶ 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()
Methods¶
__enter__ () |
|
__exit__ (*exc_info) |
|
__format__ |
default object formatter |
__init__ (thing) |
|
__new__ ((S, ...) |
|
__reduce__ |
helper for pickle |
__reduce_ex__ |
helper for pickle |
__sizeof__ (() -> int) |
size of object in memory, in bytes |
__subclasshook__ |
Abstract classes can override this to customize issubclass(). |