Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Question about basic use of a timer object from timeit module to execute code every so often in a class

Reply
Thread Tools

Question about basic use of a timer object from timeit module to execute code every so often in a class

 
 
42zeros@gmail.com
Guest
Posts: n/a
 
      07-15-2005
I would like a function to be executed every x often.
I was just wondering how to pass the following code correctly. my
object t just doesn't know what checkMail is. How can I tell it that
checkMail is a member of the class MyApp?

thanks in advance,
code is below


class MyApp(wx.App):
def OnInit(self):


frame = wxMainFrame(None, "thing")
icon = wx.Icon('foo.bmp', wx.BITMAP_TYPE_ICO)
frame.SetIcon(icon)
self.SetTopWindow(frame)

t = timeit.Timer("checkMail()","30.0")

t.timeit()
return True


def checkMail():

print "The number of messages is"

 
Reply With Quote
 
 
 
 
Robert Kern
Guest
Posts: n/a
 
      07-15-2005
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> I would like a function to be executed every x often.
> I was just wondering how to pass the following code correctly. my
> object t just doesn't know what checkMail is. How can I tell it that
> checkMail is a member of the class MyApp?


Reread the documentation for timeit. It doesn't do what you think it does.

Look at wxTimer instead.

--
Robert Kern
(E-Mail Removed)

"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter

 
Reply With Quote
 
 
 
 
42zeros@gmail.com
Guest
Posts: n/a
 
      07-15-2005
I've seen both documentation for using timeit as simply a timer to
measure preformance, but also a random page here and there that looked
to me as if they were using it as a simple timer. HOwever, if there is
a wxwidget timer I'll gladly hit that up. Thanks for the info

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Profiling weirdness: Timer.timeit(), fibonacci and memoization ssecorp Python 5 08-03-2008 11:12 PM
How to pass in argument to timeit.Timer silverburgh.meryl@gmail.com Python 3 04-30-2007 06:39 PM
How to pass arguments to the function embedded in the timeit.Timer() Dongsheng Ruan Python 1 01-19-2007 04:48 AM
timeit.timeit and timeit.repeat give different answers Dan Christensen Python 4 07-14-2004 06:54 AM
Show 4 Records that occur more often...and how often they occur. Miguel Dias Moura ASP .Net 4 05-06-2004 03:40 PM



Advertisments