Print function
In Python 2, print is a keyword. It is used without parentheses, and introducing these will lead to Python treating the parameters as a type of list (a tuple) and printing it like a list (the way repr() behaves).
In Python 3, print has been made a function. The parameters will work the same way, but must be wrapped in parentheses. Those that are already in parenthesis will now chain together the parts of the list.
In the GitHub repository, I've added this: from __future__ import print_function, which means that the converted Python 3 code is multi-language and will work in Python 2 as well.
In the book code, print is mostly used for setup and debug. The print function actually makes for more readable code, in that the \ line ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access