Prev: Python v3.1.2 documentation question
Next: Russian Spies ???? This is Hilarious !!!!! Does anyone BELIEVE it ? after 911 Inside JOB and ANTHRAX
From: Rami Chowdhury on 30 Jun 2010 03:03
On 2010-06-30 06:39, rik wrote:
> Ben Kaplan <bsk16 <at> case.edu> writes:
> > Let's take this code as an example:
> > def foo() :
> > return None
> > import profile
> > profile.run(foo())
> > What does the profile.run call do?
> > First thin it does is evaluate foo(), which returns None. So you're calling
> > profile.run(None)
> > There's nothing special about profile.run- you have to hand it something to
> > execute, not something already executed. Try calling
> > Profile.run(doSomething) # no parenthesis for doSomething.
> > >
> > > --
> > > http://mail.python.org/mailman/listinfo/python-list
> hi Ben, right: i have a top-level function main() that runs just
> fine. but i give it as an argument to cProfile.run() or profile.run(),
> it executes as expected, but then:
> > File "/var/folders/lu/luGJNSGwE0mO84R+YbcKpU+++TI/-Tmp-/python-439Ffi.py",
> line 544, in ?
> > profile.run(main(seedFile),'/Data/tmp/fetchProfile_100629.profile')
Looks like the same problem. As Ben pointed out, you need to pass profile.run() an executable
(e.g. the main() function itself) and not something that's already been
executed. Since you've already called main(seedFile), it's the return value
that is being passed to profile.run(), and that's why it's complaining...
Perhaps you meant:
From: rik on 30 Jun 2010 03:09
Ben Kaplan <bsk16 <at> case.edu> writes:
> There's nothing special about profile.run- you have to hand it something to
> execute, not something already executed. Try calling
> Profile.run(doSomething) # no parenthesis for doSomething.
your hint and REREADING THE DOCUMENTATION made me realize it
was the QUOTE MARKS on the function call i was missing:
Harit, perhaps this was your problem, too?
Ben, thanks for your help.