Intermediate
Python
Q50 / 101
What is a context manager?
Correct! Well done.
Incorrect.
The correct answer is B) An object implementing __enter__ and __exit__ used with the with statement for resource management
B
Correct Answer
An object implementing __enter__ and __exit__ used with the with statement for resource management
Explanation
with open("file") as f: calls __enter__ on entry and __exit__ on exit (even on exception), ensuring the file is always closed.
Progress
50/101