When I try to use print
without parentheses on a simple name in Python 3.4 I get:
>>> print max
Traceback (most recent call last):
...
in additions to those excellent answers, without even looking at the source code, we could have guessed that the print
special error message was a kludge:
so:
print dfjdkf
^
SyntaxError: Missing parentheses in call to 'print'
but:
>>> a = print
>>> a dsds
Traceback (most recent call last):
File "", line 1
a dsds
^
SyntaxError: invalid syntax
even if a == print
but at that stage, it isn't evaluated yet, so you get the generic invalid syntax message instead of the hacked print
syntax message, which proves that there's a kludge when the first token is print
.
another proof if needed:
>>> print = None
>>> print a
Traceback (most recent call last):
File "C:\Python34\lib\code.py", line 63, in runsource
print a
^
SyntaxError: Missing parentheses in call to 'print'
in that case print == None
, but the specific message still appears.