In Python 2.x, print actually has a special operator, not a * function.
That is why it cannot be used like: lambda x: print x
Note that (expr) does not create a Tuple (this leads to expr ), but does. This probably leads to confusion between print (x) and print (x, y) in Python 2.7
(1) # 1 -- no tuple Mister! (1,) # (1) (1,2) # (1,2) 1,2 # 1 2 -- no tuple and no parenthesis :) [See below for print caveat.]
However, since print is a special syntax operator / grammar construct in Python 2.x, without a bracket, it processes , special way - and does not create a Tuple. This special handling of the print statement allows it to act differently if the finite exists or not.
Happy coding.
* This print behavior in Python 2 can be changed to the behavior of Python 3:
from __future__ import print_function
user166390 May 31 '11 at 4:25 2011-05-31 04:25
source share