Import statements for timeit module

bruno at modulix onurb at xiludom.gro
Fri Nov 11 10:29:58 EST 2005


ChaosKCW wrote:
> Hi
> 
> I was wondering if someone could help with the import statements needed
> to use the timeit module in the following code. I need to access the
> "cur" object.
> 
> Thanks,
> 
> import cx_Oracle
> import timeit
> 
> def VerifyTagIntegrity(con, TableOwner):
>     cur = con.cursor()
>     sql = 'select (select count(*) from %s.f4111) as F4111_COUNT,
> (select count(*) from %s.f4111_tag) as TAG_COUNT from dual;' %
> (TableOwner, TableOwner)
>     print "      SQL: %s" % (sql)
>     timer = timeit.Timer('cur.execute(sql)', 'from __main__ import
> cur')
>     print timer.timeit()
> 

'cur' is local to the function, so it's not an attribute of your module,
so you can't hope to import it anyway.


-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"



More information about the Python-list mailing list