In python interpreter, I can define a function to be 1 but not print(1)
>>> lambda: 1
<function <lambda> at 0x023D03F0>
>>> lambda: print(1)
File "<stdin>", line 1
lambda: print(1)
Why?
This happens because (at least in traditional Python 2), print is not a function, it's a statement - so it doesn't make sense in the body of a lambda.
In Python 3, or in Python 2 with the print_function option enabled, print is a function, and it does work in a lambda:
>>> from __future__ import print_function
>>> lambda: print(1)
<function <lambda> at 0x7f69ab049578>
>>>