[Python-ideas] A suggestion for Python 3 vs Python 2
Barry Warsaw
barry at python.org
Tue Nov 12 20:22:04 CET 2013
On Nov 12, 2013, at 11:45 AM, Xuancong Wang wrote:
>I notice that one major change in python 3 is that it makes 'print' as a
>standard function, and it will require typing (). I do understand that it
>makes python language more consistent because most of the python
>functionalities are implemented as function calls.
>
>As you know, reading from and writing to IO is a high frequency operation.
>By entropy coding theorem (e.g. Huffman coding), an efficient language
>should assign shorter language code to more frequent tasks. Typing a '('
>requires holding SHIFT and pressing 9, the input effort is much higher than
>that in Python 2. Also, specifying IO has changed from >>* to file=*, which
>also becomes more inconvenient.
You can blame me for the original print>> syntax, which was the best of the
worst suggestions for extending the print statement in Python 2. I also had a
hard time making the mental and physical (muscle memory) switch to print()
function in Python 3.
Having used print() now for several years in both Python 3 and Python 2[*], I
can say without hesitation that I'm really glad this change was made. print
as a function is just so much better in so many ways. I particularly like the
ease with which it can be mocked for testing.
-Barry
[*] from __future__ import print_function
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20131112/6ed2c804/attachment.sig>
More information about the Python-ideas
mailing list