Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is print not a function in python?

Tags:

python

Why is print a keyword in python and not a function?

like image 500
user538442 Avatar asked Dec 10 '10 22:12

user538442


People also ask

Is print a function in Python?

Print FunctionThe Python print() function takes in any number of parameters, and prints them out on one line of text. The items are each converted to text form, separated by spaces, and there is a single '\n' at the end (the "newline" char).

Is print a keyword or a function in Python?

Print was a keyword in Python 2 but has become a function in Python 3.

Why is the print statement considered a function?

For users, making print a function lets you use print as an expression, unlike the print statement which can only be used as a statement. As an example, let's say you wanted to print an ellipsis after every line to indicate that more work was to be done.


1 Answers

Because Guido has decided that he made a mistake. :)

It has since been corrected: try Python 3, which dedicates a section of its release notes to describing the change to a function.

For the whole background, see PEP 3105 and the several links provided in its References section!

like image 156
Brandon Rhodes Avatar answered Oct 20 '22 09:10

Brandon Rhodes