How to periodically execute a function and send parameters to it. I found this example in the web which execute functions periodically. I would like to know how to send parameters to those functions.

import threading

def do_every (interval, worker_func, iterations = 0):
if iterations != 1:
threading.Timer (
do_every, [interval, worker_func, 0 if iterations == 0 else iterations-1]
).start ()

worker_func ()

def print_hw ():
print "printing hw"

def print_so ():
print "printing so"

# call print_so every second, 5 times total
do_every (1, print_so, 5)

# call print_hw two times per second, forever
do_every (0.5, print_hw)

I tried modifying it as

def print_hw (i):
print i
print "printing hw"

do_every (0.5, print_hw(5))

this gives a error. What is the proper way