The other day I accidentally wrote
print("a function?")
in my Python 2.7.11 console and was quiet astonished that it would work instead of throwing an error. I assumed, there was an implicit
from __future__ import print_function
and tried
print "also a statement???"
which also worked! Note that, when importing from __future__
the statement is disabled. It is in fact disabled, and only the function sytax works if I import print_function
I couldn't find anything in the documentation, the Python docs still read:
Note: This function is not normally available as a built-in since the
name print is recognized as the print statement. To disable the
statement and use the print() function, use this future statement at
the top of your module: (...)
What did I miss? Why is print
a statement and a builtin function in Python 2.7?