[IPython-dev] Feature request/how?

Fernando.Perez at colorado.edu Fernando.Perez at colorado.edu
Tue Feb 22 13:09:13 CST 2005


Quoting Ville Vainio <vivainio at kolumbus.fi>:

> On Tue, 2005-02-22 at 09:29 -0500, Charles Moad wrote:
>
> >	Is it not possible to include assignment operators as well?  Only
> >simple expressions seem to work.
>
> Yeah, that's because the code uses eval instead of exec. It might make
> more sense to use exec.

But if you use exec, there's nothing to return, which the OP wanted.  The
generic solution has to check whether the given code compiles as an expression
or not, and use eval/return or exec/no return accordingly.  That's what I
suggested.

> However, I can't help but think something like this should be done with
> the "timeit" module. I don't know if there is a way to force it to use
> ipython's namespace instead of the namespace of timeit-module - perhaps
> this is something that could be done with a patch to the timeit module.

Yes, but timeit is python 2.3 only, and I still support 2.2.  That's why I went
with a more pedestrian approach.

Best,

f




More information about the IPython-dev mailing list