New: Intelligent Flashcards spaced-repetition decks for every topic, built to make things actually stick.
What does Python guarantee about the body of with cm as x: ...?
with cm as x: ...
Python suppresses any exception raised inside the body so the program continues
cm.__enter__() runs before the body and cm.__exit__() runs after, even if the body raises an exception
cm.__enter__()
cm.__exit__()
__exit__ only runs if the body completes without raising an exception
__exit__