ADVERTISEMENT

How to suppress output in Google Colaboratory cell which executes a command line script (line starts with `!`) via a function

you can use '%%capture' magic function in a cell(without quotes) to suppress the output of that particular cell whether it uses a command-line code or some python code, magic function is basically a property of jupyter notebooks but since google colab is built over this, it will work there also. eg:

%%capture
!wget https://github.com/09.10-20_47_44.png

Use capture_output from python's utilities:

from IPython.utils import io
for v in range(10):
    print(v)
    with io.capture_output() as captured:
      installAdjust()

For the future, whenever a magic function doesn't suffice, search for the core properties being accessed and access them yourself.

Answer sourced from: How do you suppress output in IPython Notebook?