That's  it - thank you!

2012/1/3 Alan Etkin <[email protected]>

> I tried the code but changed the import path with this:
>
> from applications.<app name>.modules.mymodule import ff
>
> This way the action works. I don't like the fact that the actual app
> name has to be passed anyway. A workaround would to use interpolation
> and the request.application variable.
>
> Still, i don't find a way to measure the function code from the same
> controller, as in your first post
>
> On 3 ene, 12:44, Martin Weissenboeck <[email protected]> wrote:
> > Now I have tried:
> >
> > from mymodule import ff
> >
> > def ff2():
> >     return dict(a=ff())
> >
> > def tm():
> >     import timeit
> >     t1 = timeit.Timer(stmt='a=2*3').timeit(number=100)/100
> >     t2 = timeit.Timer(stmt='a=ff()',
> >       setup='from mymodule import ff').timeit(number=100)/100
> >     return dict(t1=t1, t2=t2)
> >
> > ff2 is ok, but tm gives
> > <type 'exceptions.ImportError'> No module named mymodule
> >
> > 2012/1/3 Alan Etkin <[email protected]>
> >
> > > I think that there is a problem with importing functions inside
> > > controllers "directly". You could place the function in a module (i.e
> > > in modules/mymodule.py and do from mymodule import ff)
> >
> > > On 3 ene, 05:07, Martin Weissenboeck <[email protected]> wrote:
> > > > Hi,
> > > > I want to measure some times.
> >
> > > > My code:
> >
> > > > def ff():
> > > >     return 2*3
> >
> > > > def tm():
> > > >     import timeit
> > > >     t1 = timeit.Timer(stmt='a=2*3').timeit(number=100)/100
> > > >     t2 = timeit.Timer(stmt='a=ff()',setup='from __main__ import
> > > > ff').timeit(number=100)/100
> > > >     return dict(t1=t1, t2=t2)
> >
> > > > t1 is ok, but t2 gives an error: ImportError: cannot import name ff
> > > > I understand, that __main__ is not a good idea, but what would be the
> > > > correct name?
> >
> > > > Regards, Martin
> >
> >
>

Reply via email to