Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in Python by (12.7k points)

I comprehend what print does, however of what "type" is that language component? I believe it's a capacity/function, yet for what reason does this fall flat? 

>>> print print

SyntaxError: invalid syntax

Isn't print a capacity/function? Shouldn't it print something like this?

>>> print print

<function print at ...>

1 Answer

0 votes
by (26.4k points)

In 2.7 and down, print is an assertion. In python 3, print is a function. To utilize the print work in Python 2.6 or 2.7, you can do 

>>> from __future__ import print_function

>>> print(print)

<built-in function print>

See this segment from the Python Language Reference, just as PEP 3105 for why it changed.

Want to learn python to get expertise in the concepts of python? Join python certification course and get certified

Related questions

0 votes
1 answer
asked Mar 23, 2021 in Python by Rekha (2.2k points)
0 votes
1 answer
0 votes
0 answers

Browse Categories