numpy.
disp
Display a message on a device.
Message to display.
Device to write message. If None, defaults to sys.stdout which is very similar to print. device needs to have write() and flush() methods.
sys.stdout
print
write()
flush()
Option whether to print a line feed or not. Defaults to True.
If device does not have a write() or flush() method.
Examples
Besides sys.stdout, a file-like object can also be used as it has both required methods:
>>> from io import StringIO >>> buf = StringIO() >>> np.disp(u'"Display" in a file', device=buf) >>> buf.getvalue() '"Display" in a file\n'