Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
"from __future__ import division" stops script from running (SOLVED)
-
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 <PRE>from future import division</PRE> 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 <i>before</i> I imported the scene module. Strange :P
-
There cannot be any other imports before a <code>future</code> import. Here's a quote from the <a href="http://docs.python.org/2/reference/simple_stmts.html#future">Python documentation</a>:<blockquote>
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.
</blockquote>
-
I didn't know that, thanks for clearing that up for me @omz :)