![]() |
Evaluating a Function After X Seconds: Python Equivalent to JavaScript's SetTimeout() Function
Hi all,
Not exactly new to Python, just have not programmed a time dependent function using it before. I imagine that many of you may also program some JavaScript and may be familiar with JavaScript's SetTimeout( expression, after time interval in milliseconds) function. Does Python have an equivalent to this? A SetTimeout-like Python function would be ideal for my application. Best, Y-coci |
Re: Evaluating a Function After X Seconds: Python Equivalent to JavaScript's SetTimeout() Function
Yea -- the "sched" class is exactly what you need. Just import sched
and then use it to schedule a function call in the future, either using relative time or an absolute time. The python help file tells you how in detail. - Ken ycoci0@gmail.com wrote: > Hi all, > > Not exactly new to Python, just have not programmed a time dependent > function using it before. > > I imagine that many of you may also program some JavaScript and may be > familiar with JavaScript's SetTimeout( expression, after time interval > in milliseconds) function. Does Python have an equivalent to this? > > A SetTimeout-like Python function would be ideal for my application. > > > Best, > > Y-coci |
Re: Evaluating a Function After X Seconds: Python Equivalent to JavaScript's SetTimeout() Function
On 11 Jun 2006 20:01:28 -0700, ycoci0@gmail.com declaimed the following
in comp.lang.python: > I imagine that many of you may also program some JavaScript and may be > familiar with JavaScript's SetTimeout( expression, after time interval > in milliseconds) function. Does Python have an equivalent to this? > I don't know? How does "SetTimeout" actually behave? Asynchronously? Synchronously? That is... would import time print "I'm tired" time.sleep(60) print "Ah, a short nap" be the type of behavior you are wanting? Or do you mean you want to do other stuff while the timer is running, then have the program interrupted to run the timed function, and then return to the main program? -- Wulfraed Dennis Lee Bieber KD6MOG wlfraed@ix.netcom.com wulfraed@bestiaria.com HTTP://wlfraed.home.netcom.com/ (Bestiaria Support Staff: web-asst@bestiaria.com) HTTP://www.bestiaria.com/ |
Re: Evaluating a Function After X Seconds: Python Equivalent to JavaScript'sSetTimeout() Function
Dennis Lee Bieber schrieb:
> I don't know? How does "SetTimeout" actually behave? Asynchronously? > Synchronously? That is... would The former. It is the poor-mans threading of JavaScript so to speak. Diez |
| All times are GMT. The time now is 03:14 PM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.