from future import scope problem

Terry Reedy tjreedy at udel.edu
Thu Mar 12 19:46:17 EDT 2009


mykhal wrote:
> hi,
> importing from __future__ seems to have no effect when invoked in
> local scope using exec statement.
> I supposed
> 
> g = {}
> exec 'from __future__ import division' in g
> eval('1/2', g)
> 
> should yield 0.5, but it yields 0.
> 
> is it OK, or a bug?

Please to read the fine manual.

tjr

ps.

" future statement must appear near the top of the module. The only 
lines that can appear before a future statement are:

the module docstring (if any),
comments,
blank lines, and
other future statements.
"




More information about the Python-list mailing list