Unpacking
1 | for index, item in enumerate(some_list): |
A context manager is a python object that provides extra contextual information
to an action. Context managers are a way of allocating and releasing some sort of resources exactly where you need it.
The most well known example is file access:1
2with open('file.txt') as f:
contents = f.read()
f’s close method will be called at some point.