newbie division question

casevh at comcast.net casevh at comcast.net
Mon Sep 18 15:34:50 EDT 2006


David Isaac wrote:
> Suppose x and y are ints in moduleA.
>
> If I put
> from __future__ import division
> in moduleA then x/y will produce the truediv result.
>
> If I put
> from __future__ import division
> in moduleB
> and
> from moduleB import *
> in module A
> then x/y will NOT produce the truediv result
> (in moduleA).
>
> Why?
The statement "from __future__ import division" in ModuleB influences
the byte codes generated when ModuleB is compiled. It doesn't influence
the byte code generated in ModuleA.
> And is there some way to avoid importing
> from __future__ in module after module?
Start python with the "-Qnew" option.
> 
> Thanks,
> Alan Isaac

casevh




More information about the Python-list mailing list