[Tutor] A slight bug in IDLE

Steven D'Aprano steve at pearwood.info
Sat Jul 13 12:11:48 CEST 2013


On 13/07/13 18:39, Jim Mooney wrote:
> On 13 July 2013 00:54, eryksun <eryksun at gmail.com> wrote:
>
>
>> A __future__ import modifies compilation of the current module.
>>
>
> Hmm, so if I import a module that uses truncated division, that's what I
> get, even though I imported __future__ division. OTOH, a non-future import
> will be used by a module imported after it. That's a gotcha to avoid ;')


No, actually, it's the opposite of a gotcha. If a module expects to use truncated division, and *fails* to "from __future__ import division", that's what it needs to get. If your import would change what the other module sees, then you could change the behaviour of the other module (and probably break it) just by importing something from __future__.

By the way, you can import __future__, but when you do, it is just an ordinary module with no superpowers. Only the "from __future__ import ..." in the first or second line of code has superpowers. Try this:

import __future__
dir(__future__)


-- 
Steven


More information about the Tutor mailing list