dbader / schedule

Python job scheduling for humans.
https://schedule.readthedocs.io/
MIT License
11.62k stars 954 forks source link

change_func() method in jobs #599

Open VictorioMaculan opened 9 months ago

VictorioMaculan commented 9 months ago

So, I created this exciting method, job().change_func(), because I think it would be cool to allow the users to change the job's function in a more implicit way, and, it also helps to keep the function metadata. Take a look:

def hello(name):
    print(f'Hello, {name}!')

sch = schedule.every().second.do(hello, 'folks')

while True:
    if timer >= 10:
        sch.change_func(hello, 'friends') # Right here

    schedule.run_pending()

But what do you guys think? Sorry for anything, it's my first time contributing :)