Lemon.io interview question

What are python context managers?

Interview Answer

Anonymous

1 Mar 2023

A pratical way to manage critical accesses to a certain functionality. A basic example of it would be to open a file: This can be done by using the "with" statement which, in turn, will use the respective "__enter__" and "__exit__" methods to handle the action of opening and closing a file.

1