blob: d4f50abe2cfe71c381fa4ae87ce848bf8b47ec86 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
---
tags:
- python
---
Use `contextlib.closing` to automatically close something at the end of a block.
```
with closing(blaat) as b:
b.do_something(b)
```
is equal to
```
try:
b.do_something()
finally:
b.close()
```
This is used for example with taskflow's [[Persistence]].
|