Is there idiomatic way to reload python modules on edit? I am keeping configuration in my_config_module.py file and want to automatically detect and load config changes. Currently I am trying something like this but I find it ugly and unsafe:
import my_config_module
import importlib
last_modification = os.stat('my_config_module.py').st_mtime
while True:
    last_mod = os.stat('my_config_module.py').st_mtime
    if last_mod != last_modification:
        importlib.raload(my_config_module)
        last_modification = last_mod 
    # main loop, some of my code     
    
watchdogmodule might be helpful.