My basic understanding of the "with"-idiom is this:
Calling
with obj:
further code.. inside with
#endwith
code after if block
means that after the with-block ended, the __exit__ method on obj will be called.
However, assume I have the with-call within a function definition, and inside it, the code has the following structure:
def fct():
with obj:
return call_other_fct(params)
Now my question: When does the __exit__ run?
- After the execution of the return statement
- Before the execution of the return statement but after the call to
call_other_fct - It does not run at all