I am trying to find the best way to schedule a function to execute in my python program. Currently I have the following code; which works but I am curious if there is a better way.
from datetime import datetime
start_time = datetime(2019, 7, 26, 14, 48, 10, 28061)
def do_something():
return 2+2
while True:
if (datetime.now() > start_time):
do_something()
break
Is this a BAD way to do this? Is there a better way to do this? Thanks to all of those who reply in advance.