[IPython-user] from __future__ import division

Fernando Perez Fernando.Perez at colorado.edu
Mon Dec 19 15:26:47 CST 2005

Harri Pasanen wrote:

> Hmm.. doesn't seem to work for me, at least not with
> ./downloads/ipython-0.6.15-py23.noarch.rpm installed on Python 2.3.3
> that came with Mandrake Linux 10.0.
> I'm tempted to chalk this up as a bug/limitation in the __future__
> implentation of Python itself.  Looks like it takes effect only in the
> execution context of the __future__ import, and as it is not really a
> namespace thing, passing namespaces does not help...

well, that's odd, it certainly works for me:

planck[~]> ip
Python 2.3.4 (#1, Feb  2 2005, 12:11:53)
Type "copyright", "credits" or "license" for more information.

IPython 0.6.16.svn -- An enhanced Interactive Python.
?       -> Introduction to IPython's features.
%magic  -> Information about IPython's 'magic' % functions.
help    -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.

In [1]: 4/3
Out[1]: 1.3333333333333333

Note that I'm running from SVN, but I doubt that has anything to do with this 
issue.  All I did was put in my ipythonrc file the line I mentioned:

execute exec __IP.compile('from __future__ import 
division','<input>','single') in __IP.shell.user_ns

I can confirm (I triple-checked) that commenting this out gives me 4/3->1, 
while keeping it in produces the result above.  Perhaps there's a subtle 
difference between python 2.3.3 and 2.3.4 on this matter, but that also sounds 

At any rate, if the solution you posted (-q new) works for you, that's great. 
  I just wanted to clarify that this one does work at least on my system, 
though I'm at a loss to guess why it fails for you.



More information about the IPython-user mailing list