More about import
Importing loads a module into memory. For that reason, changing a file while it's running will not change the running program. Likewise, if you import a file into the interactive interpreter, it won't know about changes to the file.
# timer.py
import schedule
import time
import os
import pottery
# Executes super important pottery routine every minute.
# But we want some consistent pottery and also some
# more experimental pottery!
def make_consistent():
pottery.make()
def make_wabisabi():
os.system("python -c 'import pottery; pottery.make()'")
schedule.every(1).minutes.do(make_consistent)
schedule.every(1).minutes.do(make_wabisabi)
while True:
schedule.run_pending()
time.sleep(1)
# pottery.py
def make():
print("Here's a perfectly nice pot for you!")
If we start timer.py, it will make 2 perfectly nice pots every minute.
If we change pottery.py at some point to make lumpy pots, we'll start getting one perfectly nice pot and one lumpy pot every minute from that point on.
You can also find this code here.