How does CO_FUTURE_DIVISION compiler flag get propagated?

Terry twestley at gmail.com
Sat Jul 2 20:07:02 EDT 2011


On Jul 2, 3:55 pm, Hrvoje Niksic <hnik... at xemacs.org> wrote:
> Terry <twest... at gmail.com> writes:
> > Future division ("from __future__ import division") works within
> > scripts executed by import or execfile(). However, it does not work
> > when entered interactively in the interpreter like this:
>
> >>>> from __future__ import division
> >>>> a=2/3
>
> Are you referring to the interactive interpreter normally invoked by
> just running "python"?  That seems to work for me:
>
> Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53)
> [GCC 4.5.2] on linux2
> Type "help", "copyright", "credits" or "license" for more information.>>> 2/3
> 0
> >>> from __future__ import division
> >>> 2/3
>
> 0.6666666666666666

Yes, that works for me on my Mac. The problem I'm having is in a
Python interpreter that I built for the iPhone. It uses
PyRun_SimpleString() to execute user entered commands. After you
import future division, it does not seem to remember it on subsequent
commands.



More information about the Python-list mailing list