omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    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)

    Pythonista
    2
    3
    1906
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Sebastian
      Sebastian last edited by

      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

      1 Reply Last reply Reply Quote 0
      • omz
        omz last edited by

        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>
        1 Reply Last reply Reply Quote 0
        • Sebastian
          Sebastian last edited by

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

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Powered by NodeBB Forums | Contributors