Rationale
Spillover of temporary variables can be a significant annoyance when working with Jupyter notebooks.
Aesthetically and logistically, it's bothersome to have a del var1, var2, var3
hanging around at the bottom
of a notebook cell to take care of cleanup of these temp variables. It prevents a Ctrl+End
from going to the end of relevant code, and if an Exception is raised in the course of code execution
the del
cleanup doesn't happen.
A short content manager class takes care of these various problems:
when execution leaves the with
suite, even due to a raised exception, the indicated variables are deleted.