[IPython-user] from __future__ import division
Fernando Perez
Fernando.Perez at colorado.edu
Fri Dec 16 13:06:39 CST 2005
Hi all,
Darren Dale wrote:
> On Friday 16 December 2005 11:50, Harri Pasanen wrote:
>
>>Hi,
>>
>>I've been looking for a way to automatically enable 3/4=0.75 style division
>>in ipython, but
>>so far no luck.
>>
>>execute from __future__ import division
>>
>>in ipythonrc does not do it, and to me it it looks currently impossible to
>>do in general from pure python.
>>
>>Am I missing something, is there a way?
>
>
> I would also like to know how to do this, at least for the -pylab and -p scipy
> modes.
this one was a bit tricky to get to work, and I'm not exactly sure why. 'exec'
was failing in all the simple forms I tried, but eventually I got it to work
with a compiled code object. It's not clear to me why passing 'exec' a string
would produce different results than passing it a compiled code object, but
I'm in a hurry so I'll have to read up on exec's subtleties later.
To make this work, just put the following into your ~/.ipython/ipythonrc file.
Please note that this should be a SINGLE LINE, my mail client splits it into
two. Piece it back together in the ipythonrc file so it's only one line.
execute exec __IP.compile('from __future__ import
division','<input>','single') in __IP.shell.user_ns
Cheers,
f
More information about the IPython-user
mailing list