1.6.84. numpy.disp¶
-
numpy.disp(mesg, device=None, linefeed=True)[source]¶ Display a message on a device.
Parameters: mesg : str
Message to display.
device : object
Device to write message. If None, defaults to
sys.stdoutwhich is very similar toprint. device needs to havewrite()andflush()methods.linefeed : bool, optional
Option whether to print a line feed or not. Defaults to True.
Raises: AttributeError
If device does not have a
write()orflush()method.Examples
Besides
sys.stdout, a file-like object can also be used as it has both required methods:>>> from StringIO import StringIO >>> buf = StringIO() >>> np.disp('"Display" in a file', device=buf) >>> buf.getvalue() '"Display" in a file\n'