Python

Python from __future__ import syntax error

At long last I got my Unisa registration for this semester sorted. Unfortunately I could only register for 2 modules (these cover C++ and Python) as it was extremely difficult to talk to a human at Unisa to find out what is going on.

Anyway! Busy working through the text book for INF1511 (Introduction to Python Programming and Developing GUI Applications with PyQT) I ran into a problem with importing the division module/class(?)

The import I need is for true division (from __future__ import division) and the book’s space are not really visible. I typed from__future__import division as per the text book and when I run the program received the below syntax error.

It took some digging and testing for me to find out that the statement should have a space in-front and after __future__ . It should be from (space) __future__ (space) import (space) division. i.e from __future__ import division. Note the 2 underscores before and after future.

Hope this helps anyone else that struggled to get this simple statement working.

Leave a Reply

Your email address will not be published. Required fields are marked *