Use print
as a function, import it from __future__
in Python2:
>>> from __future__ import print_function
>>> def foobar(x):
return x*x if x else print ('x is None-y')
...
>>> foobar(0)
x is None-y
>>> foobar(2)
4
Another alternative will be to use sys.stdout
:
>>> import sys
>>> def foobar(x):
return x*x if x else sys.stdout.write('x is None-y\n')
...
>>> foobar(0)
x is None-y
>>> foobar(2)
4