I am a Python instructor creating Jupyter Notebooks with exercises for my students to complete.
I want each cell in the notebook to ignore any variables defined in previous cells.
I know I can reset the namespace in any cell with %reset -fs
, but I would prefer that the notebook itself issue a %reset -fs
implicitly upon any cell execution, or alternatively for the notebook to be otherwise configured not to share variables between cells.
Such sharing of variables, while a useful feature in Jupyter, can cause errors that are difficult for students to trace - for example if they mistakenly reassign sum = 5.5
in one cell and then attempt to use sum()
in a later cell.
They are new enough learners that they can become easily confused by this even after they have been told to look for it.