Back to concept

Context managers and resource cleanup

What is a Python context manager, what do __enter__ and __exit__ do, and why not just wait for garbage collection?

Answer as you would in an interview

Answer aloud or write down a few key points. The text field is optional; the review opens after your attempt.

Loading
Context managers and resource cleanup — interview question — ML Mentor