[IPython-user] from __future__ import division
Fernando Perez
Fernando.Perez at colorado.edu
Mon Dec 19 15:33:28 CST 2005
Fernando Perez wrote:
> 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:
OK, I guess I should clarify what I mean by 'works for me':
In [1]: 4/3
Out[1]: 1.3333333333333333
In [2]: ed foo.py
Editing... done. Executing edited code...
1
In [3]: cat foo.py
print 4/3
The modification I mentioned enables true division at the ipython prompt for
interactively typed statements, but it doesn't do anything for modules and
scripts you may run, because the Python VM treats the division flag as a
per-module thing. So regardless of what you do at the ipython command line,
if you want true division in your scripts, you'll still need the __future__
import explicitly there, and you'll have to do it in _each_ module where you
wish to activate true division.
I hope that is clearer now.
Cheers,
f
More information about the IPython-user
mailing list