[Edu-sig] source code from SA:10648
tim.peters at gmail.com
Fri Jul 16 16:27:37 CEST 2010
> Using print as a function is optional in 2.6 without
> importing anything special.
Nope! `print` is a statement in all 1.x and 2.x versions of Python.
When you do, say,
before Python 3.x, you're not calling a print function with an
argument of 1, you're giving the expression (1) to the print
statement. (1) is the same thing as 1, so it just prints "1".
Maybe the difference is clearer here:
Before 3.x, tjat's the same as
_x = (1, 2, 3)
That is, it's not passing arguments 1, 2 and 3 to a print function,
it's giving a single expression - the 3-tuple (1, 2, 3) - to the print
statement - and is very different from
print 1, 2, 3
(which gives 3 expressions - not just 1 - to the print statement).
It's really the same as doing, e.g.,
`return` and `print` are statements, and tacking "(1)" on does not
magically turn either into a function call, it's just adding redundant
parentheses to the expression "1".
More information about the Edu-sig