How to make Python poll a PYTHON METHOD

Nick Vatamaniuc vatamane at gmail.com
Mon May 7 22:42:08 EDT 2007


On May 7, 10:07 pm, johnny <rampet... at gmail.com> wrote:
> Is there a way to call a function on a specified interval(seconds,
> milliseconds) every time, like polling user defined method?
>
> Thanks.

Sure,

>>> def baz():
   ...:     print "Baz!"
   ...:

>>> from threading import Timer

>>> timer=Timer(5.0,baz)

>>> timer.start()

>>> Baz!


>>>


Cheers,
-Nick Vatamaniuc




More information about the Python-list mailing list