[Tutor] how to get the return value?
Anna Ravenscroft
annaraven at gmail.com
Sat Mar 4 18:49:31 CET 2006
On 3/4/06, Ingo <seedseven at home.nl> wrote:
>
> To make a time lapse video I've been playing with the sched module.
> There is one problem I run into, in the code below, how do I get the
> returned value t from printtime into main?
>
>
> import time
> from sched import scheduler
>
> class time_lapse(scheduler):
>
> def time_lapse(self, start_time, stop_time, interval, priority,
> action, argument):
> def lapse():
> action(*argument)
> i=self.enter(interval, priority, lapse, ())
> if stop_time:
> if stop_time<self.timefunc():
> self.cancel(i)
> self.enterabs(start_time, priority, lapse, ())
>
> def printtime(strf=None):
> t=time.time()
> if strf:
> print time.strftime("%Y%m%d_%H%M%S")
> else:
> print time.localtime()
> return t
>
> def main():
> schedule = time_lapse(time.time, time.sleep)
> start=time.time()
> stop=list(time.localtime(start))
> stop[3]=stop[3]+2
> stop=time.mktime(stop)
>
> #schedule.time_lapse(None,None,5,1,printtime,()) #start now, run
> forever
> schedule.time_lapse(start,stop,7,0,printtime,(1,))
>
> schedule.run()
>
>
> if __name__ == "__main__":
> main()
>
>
> Ingo
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
main(printtime(strf=None))
should do it. Alternately:
tt = printtime(strf=None)
main(tt)
Anna
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060304/5d4d4a70/attachment.htm
More information about the Tutor
mailing list