Guido on python3 for beginners
john_ladasky at sbcglobal.net
Thu Feb 18 15:22:58 EST 2016
On Wednesday, February 17, 2016 at 11:28:17 PM UTC-8, Chris Angelico wrote:
> 5) print statement/function. Py3 forces you to put parentheses on it,
> which is no different from C's printf() or Pike's write() or any
> number of other languages where console I/O needs no language support.
> Maybe a tiny TINY advantage to Py2 in the short term, but as soon as
> you introduce the less basic features, keyword arguments are way
> better than the magic syntax the statement needs. (Also, trying to
> explain the interaction between the print statement's "soft space" and
> other console I/O is not easy.) By the time you've really learned the
> language, the advantage belongs to Py3.
Another advantage to the Py3 print function over the Py2 print statement is that it makes redirecting output SO much easier. If I write a function that might sometimes print output to the console, and might at some other time print to a GUI window, or to a log file, I can just pass in the relevant output function name as an argument to my own function.
This is very helpful, and I use it often. I teach my new Python students to write their application's core logic, without regards to any GUI. Later, when I teach them to use a GUI, building it is easier because the process is modular.
More information about the Python-list