from __future__ import print_functionimport sys
if sys.version_info[:2] < (3, 3):old_print = printdef print(*args, **kwargs):flush = kwargs.pop('flush', False)old_print(*args, **kwargs)if flush:file = kwargs.get('file', sys.stdout)# Why might file=None? IDK, but it works for print(i, file=None)file.flush() if file is not None else sys.stdout.flush()
>>> from __future__ import print_function>>> help(print)print(...)print(value, ..., sep=' ', end='\n', file=sys.stdout)
Prints the values to a stream, or to sys.stdout by default.Optional keyword arguments:file: a file-like object (stream); defaults to the current sys.stdout.sep: string inserted between values, default a space.end: string appended after the last value, default a newline.