Nov-02-2018, 07:01 PM
If your function is dealing with files, it should be closing them explicitly. A with-block (or "context manager") is generally the normal way to do that.
Even if you weren't doing that, your file objects would (eventually) be closed by the garbage collector, with or without hitting the whole module, since the files are kept on the stack which is cleaned up after the function call completes.
Even if you weren't doing that, your file objects would (eventually) be closed by the garbage collector, with or without hitting the whole module, since the files are kept on the stack which is cleaned up after the function call completes.