I'd like to do the following in python:
- check if a module has been imported
- if it hasn't, then import the module using
import module_name - if it has, then reload the module using
importlib.reload(module_name)
I've tried the following, but it doesn't seem to work:
try:
importlib.reload(module_name)
except NameError:
import (module_name)
Is there perhaps a better way?