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() 5 1919
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 'o****@xiludom.gro'.split('@')])"
So timeit is mostly useless then ?
ChaosKCW <da********@gmail.com> wrote: So timeit is mostly useless then ?
No, it's a precious jewel, but if you want to use it you must allow it
to import the code you want it to run.
Alex
bruno at modulix wrote: 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,
....> 'cur' is local to the function, so it's not an attribute of your module, so you can't hope to import it anyway.
Although you could change your code as follows:
import cx_Oracle import timeit
def VerifyTagIntegrity(con, TableOwner):
global cur, sql ### 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)
XXX>> timer = timeit.Timer('cur.execute(sql)', 'from __main__ importcur')
timer = timeit.Timer('cur.execute(sql)', ###
'from __main__ import cur, sql') ### print timer.timeit()
--
-Scott David Daniels sc***********@acm.org
ChaosKCW wrote: So timeit is mostly useless then ?
I wouldn't say so.
--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom.gro'.split('@')])" This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Matthew Wilson |
last post by:
Hi-
I'm writing a bunch of classes, several of which need functions and
variables defined in the math module. In some instances, I'm going to
import my module like this:
import myshapes
...
|
by: Paul Rubin |
last post by:
That's what the Python style guides advise. They don't seem to like
def frob(x):
import re
if re.search('sdfxyz', x): ...
instead preferring that you pollute your module's global namespace...
|
by: myang |
last post by:
I am revising a python module, and try it in python shell. Each time after
the module is modified, how can I import the new module? I remember there is
an "import" like staff to do it, but dont...
|
by: Roy Smith |
last post by:
I'm playing with the timeit module, and can't figure out how to time a
function call. I tried:
def foo ():
x = 4
return x
t = timeit.Timer ("foo()")
print t.timeit()
|
by: Dennis B. Hansen |
last post by:
Hi all...
I'm having some problems JAXB compiling som schemas, and was wondering
if what i was trying to do is simply wrong... the problem seems to be
with my import statements, and I've tried...
|
by: Shane Hathaway |
last post by:
Let's talk about the problem I really want help with. I brought up a
proposal earlier, but it was only half serious. I realize Python is too
sacred to accept such a heretical change. ;-)
...
|
by: Steven D'Aprano |
last post by:
When using the timeit module, you pass the code you
want to time as strings:
import timeit
t = timeit.Timer("foo(x, y)", \
"""from module import foo
x = 27
y = 45
""")
elapsed_time =...
|
by: BartlebyScrivener |
last post by:
I know this must have been answered a hundred times, but I must be
searching on the wrong terminology.
Let's say I have a module foo.py that imports os.
I make another script called bar.py...
|
by: Phoe6 |
last post by:
Hi,
Following are my files.
In the format:
Filename
----
content
----
config1.txt
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |