3 ms·
Statements and expressions are different syntactic elements. So "x = print" will throw a syntax error in 2.6: >>> x = print File "<stdin>", line 1
by andreyf 17y ago
Statements and expressions are different syntactic elements. So "x = print" will throw a syntax error in 2.6:
>>> x = print
File "<stdin>", line 1
x = print
^
SyntaxError: invalid syntax
But not if you "from __future__ import print_function" first. This is also why __future__ imports need to be at the very top of each file they are included in (unlike other imports).
- tvon 17y agoAh yes, apologies, I completely misunderstood your statement.