Expression
1. In Python, you can use an expression as a statement, too—that is, on a line by itself.
1) for calls to functions and methods.
some functions and methods without a return value.
2) for printing values at the interactive prompt
2. Expression statements and in-place changes
expression statements are often used to run list methods that change a list in-place:
>>> L = [1, 2]
>>> L.append(3) # Append is an in-place change
>>> L
[1, 2, 3]
however,
>>> L = L.append(4) # But append returns None, not L
>>> print(L) # So we lose our list!
None
Print Operations
1. Call format
print([object, ...][, sep=' '][, end='\n'][, file=sys.stdout][, flush=False])
The sep, end, file, and (in 3.3 and later) flush parts, if present, must be given as keyword arguments—that is, you must use a special “name=value” syntax to pass the arguments by name instead of position
Keep in mind that the separator and end-of-line options provided by print operations are just conveniences, if you need to to display more complicated /specific formatting , don;t put this way, using string formatting tool
Print Stream Redirection
print (x,y)
is equivalent to
import sys
sys.stdout.write(str(x) +' ' +str(y) +'\n')
Automatic stream redirection
log = open('log.txt', 'a') # 3.X
print(x, y, z, file=log) # Print to a file-like object
print(a, b, c) # Print to original stdout
Importing from __future__
from __future__ import print_function