How to reload “from mymodule import *” wildcard imports in Jupyter

In our previous post How to reload import in Jupyter we showed how to use reload() from importlib in order to reload a module without restarting the kernel.

import mymodule
# Reload .py file every time we run the cell
from importlib import reload
reload(mymodule)

However, often we are using syntax like

from mymodule import *

to wildcard-load everything imported from mymodule.

We can reload those wildcard imports using the same strategy by additionalling importing mymodule and then reloading using reload(mymodule) – this will also reload the wildcard import from mymodule import *!

from mymodule import *

# This line is just to facilitate reloading
import mymodule
from importlib import reload
reload(mymodule)
# Reload .py file every time we run the cell from importlib import reload reload(mymodule)