On this page
numpy.disp
numpy.disp(mesg, device=None, linefeed=True)[source]-
Display a message on a device.
- Parameters
-
mesgstr-
Message to display.
deviceobject-
Device to write message. If None, defaults to
sys.stdoutwhich is very similar toprint.deviceneeds to havewrite()andflush()methods. linefeedbool, optional-
Option whether to print a line feed or not. Defaults to True.
- Raises
-
- AttributeError
-
If
devicedoes not have awrite()orflush()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'
© 2005–2021 NumPy Developers
Licensed under the 3-clause BSD License.
https://numpy.org/doc/1.20/reference/generated/numpy.disp.html