How can output to stdout
be suppressed?
A semi-colon can be used to supress display of returned objects, for example
>>> 1+1
2
>>> 1+1; # No output!
However, a function that prints to stdout is not affected by the semi-colon.
>>> print('Hello!')
Hello!
>>> MyFunction()
Calculating values...
How can the output from print
/ MyFunction
be suppressed?
Suppress output
Put a
;
at the end of a line to suppress the printing of output [Reference].Add
%%capture
as the first line of the cell. egThis simply discards the output, but the
%%capture
magic can be used to save the output to a variable - consult the docs(credit: https://stackoverflow.com/a/23611571/389812)
You could use io.capture_output:
to supress (e.g. capture) stdout and stderr for those lines within the
with-statement
.