We already know that, datetime.timedelta(hours= 5) is a proper syntax. How is it possible to pass an argument that can replace 'hours' as given in the function down below?
def check_time(until_when, def_time, how_long):
if until_when- datetime.datetime.now() > datetime.timedelta(def_time = how_long):
input('Task has been finished.\nPress any key to quit\n')
exit()
def check_time(until_when, def_time, how_long):
arg_dict = {def_time:how_long}
dt = datetime.timedelta(**arg_dict)
if until_when- datetime.datetime.now() > dt:
input('Task has been finished.\nPress any key to quit\n')
exit()
See Understanding kwargs in Python and the tutorial.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With