I have a cell that writes a class to a file
%%writefile example_class.py
class Example(object):
def __init__(self):
...implementation...
Now, I can import that class in another cell as follows:
from .example_class import Example
example = Example()
...using example...
That works all fine so far. However, when I do the following afterwards:
- Update Example class (first cell) and execute cell (overwrite)
- Execute second cell which loads Example class
The changes done in 1. are not active when I execute the second cell. The second cell still uses the first version of the Example class (without updates). Is there some way to enforce that the second cell imports the most recent version of the Example class?
One way to get things working would be to restart the environment - but I'd like to avoid that because that is very time consuming (I have lots of cells to execute before that).
Also, I really need to write the python source in the first cell to the disk. So just having a normal cell without %%writefile example_class.py
would not be an option for me.