[Pythonmac-SIG] timeit and import problem
Chris Smith
smichr at bigfoot.com
Fri Apr 15 18:02:25 CEST 2005
I was recently trying to use the timeit module and although I was able
to do so without problem on a Windows machine, I get a "cannot import
y1" ImportError from the following script.
###
import timeit
def y1():
print 'y1 executed'
def y2():
print 'y2 executed'
for f in [y1,y2]:
name = f.__name__
print name; f()
t=timeit.Timer('%s()' % name, 'from __main__ import %s' % name)
print t.timeit(1)
###
--the output--
y1
y1 executed
** ImportError
I am using the IDE for 2.3.3 under OS X (10.2.8).
I am able to successfully run timeit in other ways, but I like the
above way to loop through the codes that I want to test.
/c
More information about the Pythonmac-SIG
mailing list