code as notebook, how to reload custom module?

  Kiến thức lập trình

See the example below:

#%% cell 1
import my_custom_module

#%% cell2:
data = load_data_that_takes_a_long_time_to_load()

#%% cell 3:

result = my_custom_module.function_that_changes(data)

How can I write a python script that has those cell separations so it can run programmatically as a regular python script, yet if I’m running cells manually, I need to be able to reload a module that changed without restarting the kernel. I’ve tried using importlib.reload but to no avail.

LEAVE A COMMENT