Skip to content

Contextlib practice problems in Python

Difficulty:
Category:
Tag:

Showing 6 of 6

Status Title Difficulty
aclosing: release the connection on break, error and cancellation Hard
Async iterators: the paginator you can actually close Medium
Batched async stream: never yield inside a cancel scope Hard
contextmanager: temporarily patch an attribute, and put it back Medium
ExitStack: all-or-nothing acquisition of N resources Hard
nullcontext and suppress: use the stream you were given, close only what you opened Easy