by alextgordon · 11y ago · 0 comments
https://www.python.org/dev/peps/pep-0214/
Where he basically said "Maybe print should be a function, but... nah".
Two years later, he says he regrets it:
http://legacy.python.org/doc/essays/ppt/regrets/PythonRegret...
And the benefits are explained here:
(Sorry, trolling. ML-style function call syntax would clash a lot with other parts of Python.)
def g(): return 5
assert g() == 5
assert g != 5
Without parenthesis, how can the language distinguish the last two lines? How does ML do it? Would the same trick work in Python? I know Ruby has optional parenthesis, but functions aren't quite as first class there as they are in Python, which is why the have Proc and whatnot.Second of all it's such a silly syntactic difference that if people are honestly bothered enough by it to stay on python 2 i just lost all hope for that community. Besides, the reason for changing it was not vanity with syntax, it was to move it from a language keyword into a standard function so it could be used in all the ways described above, marvys links describe this better.
Since pretty much everything has at least one print statement, its removal ensured that everything had to be converted.
If Guido&co had tried to maintain backwards compatibility, they could have more easily made the important semantic changes (like unicode strings). Users would have been enthusiastic to upgrade, instead of angry that their time and money was being wasted on irrelevant syntax details.
People know that global variables are a bad thing but fail to realize that print "foo" is essentially equivalent to global_variable_output_buffer+="foo". It simply shouldn't be scattered around everywhere.
This is not just academic nonsense, I was once given the task to parallelize the code in a large python code base, and to send the output in an email instead of printing to console. It would have been an easy job but a lot of the code was using print just the way you describe it causing intermingled output in the console when run in parallel.