Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #19135

Re: importing and nose

Date 2012-01-19 17:49 +0000
From Andrea Crotti <andrea.crotti.0@gmail.com>
Subject Re: importing and nose
References <4F184EAF.5080603@gmail.com> <jf9kar$bon$1@dough.gmane.org>
Newsgroups comp.lang.python
Message-ID <mailman.4869.1326995401.27778.python-list@python.org> (permalink)

Show all headers | View raw


On 01/19/2012 05:36 PM, Peter Otten wrote:
>
> I don't believe you.

Quite sure it does:

[andrea@precision test]$ cat simple.py
import profile
from os import path
import sys

prof_path = path.join(path.dirname(__file__), 'profiling')
sys.path.append(prof_path)
import x


profile.run('x.f1()')
[andrea@precision test]$ cat simple.py
import profile
from os import path
import sys

prof_path = path.join(path.dirname(__file__), 'profiling')
sys.path.append(prof_path)
import x


profile.run('x.f1()')
[andrea@precision test]$ python2 simple.py
          2005 function calls in 0.057 seconds

    Ordered by: standard name

    ncalls  tottime  percall  cumtime  percall filename:lineno(function)
      1001    0.007    0.000    0.007    0.000 :0(range)
         1    0.007    0.007    0.007    0.007 :0(setprofile)
         1    0.000    0.000    0.050    0.050 <string>:1(<module>)
      1000    0.037    0.000    0.043    0.000 b.py:1(f2)
         0    0.000             0.000          profile:0(profiler)
         1    0.000    0.000    0.057    0.057 profile:0(x.f1())
         1    0.007    0.007    0.050    0.050 x.py:4(f1)



But in general you're perfectly right, I forgot about this profile 
"issue", calling
profile.runctx('x.f1()', locals=locals(), globals=globals())
works, even if maybe I don't even need to pass so much, but the x location
would be enough..

Why does the simple example works then?

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: importing and nose Andrea Crotti <andrea.crotti.0@gmail.com> - 2012-01-19 17:49 +0000

csiph-web