Forum Archive

"from __future__ import division" stops script from running (SOLVED)

Sebastian

Ok, so I'm trying to create a scene based calculator and everything works fine, except the division part. If you type 3/2 you get 1 as the answer, because python 2.x uses floor division on integers. So then I thought I could just do

from future import division
but that seems to stop the script from running at all.

Why does the script fail to start when I try to import division? Is it just me, or does it happen to everyone?
PS: It's only when I'm using the scene module, it works just fine with console based applications.

Edit: I got it working now when I imported division before I imported the scene module. Strange :P

omz

There cannot be any other imports before a future import. Here's a quote from the Python documentation:


A 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.

Sebastian

I didn't know that, thanks for clearing that up for me @omz :)