Configure day based on string input
userinput = wednesday
usertime = "18:30"
schedule.every().userinput.at(usertime).do(function)
The above does not work as they do not detect the variable's value for userinput but works for usertime
By writing schedule.every().userinput.at(usertime)., Python thinks you want to access a variable userinput located inside schedule.every(), which doesn't exist.
Unfortunately there is no function available to choose the day of the week based on the content of a variable. At the moment your best guess would be to do a bunch of ifs:
import schedule
def at_day(job, day_name):
if day_name == "monday":
return job.monday
if day_name == "tuesday":
return job.tuesday
if day_name == "wednesday":
return job.wednesday
if day_name == "thursday":
return job.thursday
if day_name == "friday":
return job.friday
if day_name == "saturday":
return job.saturday
if day_name == "sunday":
return job.sunday
raise Exception("Unknown name of day")
userinput = "wednesday"
usertime = "18:30"
job = at_day(schedule.every(), userinput).at(usertime).do(lambda: print("hi"))
print(job.next_run)
They should define a __getitem__ that calls the correct property on the job object, so we can invoke schedule.every()[userInput].at(userTime).do(function) where userInput would be a string ("monday", "tuesday", ...)