evaluation question

Mark Bourne nntp.mbourne at spamgourmet.com
Tue Jan 31 16:00:53 EST 2023


Greg Ewing wrote:
> On 30/01/23 10:41 pm, Muttley at dastardlyhq.com wrote:
>> What was the point of the upheaval of converting
>> the print command in python 2 into a function in python 3 if as a 
>> function
>> print() doesn't return anything useful?
> 
> It was made a function because there's no good reason for it
> to have special syntax in the language.

I think I saw somewhere that making print a function also had something 
to do with being able to add extra keyword arguments like sep and end. 
The syntax for printing to a specific file already seemed a bit odd with 
the print statement, and adding extra arguments would have made it even 
more clunky (yeah, I know ">>" is similar to C++ streams, but it looks 
out of place in Python).

They couldn't fully make the change from print statement to print 
function without breaking backward compatibility for existing code.  But 
there were other breaking changes being made in Python 3 anyway, so may 
as well sort print out while at it and have all the breaking changes at 
once.

> Functions don't need to return things to justify their existence,
> and in fact the usual convention is that functions whose purpose
> is to have an effect just return None.

-- 
Mark.


More information about the Python-list mailing list