Using print() (the function version) in Python2.x

Consider the following expressions:

a = ("Hello SO!")
a = "Hello SO!"

They’re equivalent. In the same way, with a statement:

statement_keyword("foo")
statement_keyword "foo"

are also equivalent.

Notice that if you change your print function to:

print("Hello","SO!")

You’ll notice a difference between python 2 and python 3. With python 2, the (...,...) is interpteted as a tuple since print is a statement whereas in python 3, it’s a function call with multiple arguments.

Therefore, to answer the question at hand, print is evaluated as a statement in python 2.x unless you from __future__ import print_function (introduced in python 2.6)

Leave a Comment