notebook
notebook copied to clipboard
%load does not update
Description
In a python field, one may load python files with %load file.py.
This works fine, but what is done is,
the line %load file.py is commented out
and after it, the file is inserted in the cell.
The result is
# %load file.py
<here comes the file>
The problem with this is, that if the file changes, the inserted text does not change and what is really recomputed is what is effectively what is in the cell disregarding the changed file.
Reproduce
Very simple, wirte f ile $file.py$, write a minimum notebook with a single cell of type python
containing just %load file.py.
Running the cell shows the behavior.
Expected behavior
There are several possibilities for a decent behavior.
I would prefer to keep the cell unchanged
and just interpret the line %load file.py as if there would be the content of the file in the current version.
I would not mind that the details are invisible.
If One cares, the solution is more difficult.
maybe replacing %load file.py by
<here comes the file
Context
I think this does not depend on context at all.
For context, here are the docs for the %load magic command.
I think what you want goes beyond what %load is meant to do, which is just insert text into the cell. For customizing or defining new magics, you probably need to read about making those kind of customizations in ipython.
Does anyone else have a better suggestion? I don't think this is possible with the JupyterLab extension system (which Notebook 7 is built off on top of).