0

I'm new to Jupyter notebooks but a python developer, so it seems obvious to me to split my long complex code in different modules, that in this case are notebooks.

I have:

  • notebook1.ipynb
    • In here I import the data, and make data cleaning
    • This produces outputs, there are many print functions
  • notebook2.ipynb
    • analysis and charts

As one of the first thing in notebook2 I import the other one:

%run notebook1.ipynb

This will correctly import and run the notebook as well as put all variables in scope. But it will also print everything that was printed from notebook1.

QUESTION: Is there a way to suppress the output of external jupyter notebooks?

Leonardo
  • 4,046
  • 5
  • 44
  • 85
  • if you don't what to display it then don't use `print()` – furas Jan 30 '21 at 02:32
  • [IPython: redirecting output of a Python script to a file (like bash >)](https://stackoverflow.com/questions/14571090/ipython-redirecting-output-of-a-python-script-to-a-file-like-bash) – furas Jan 30 '21 at 02:33
  • I want to use print when cleaning my data on notebook1. Once it's done I won't work on notebook1 anymore, just run it via notebook2, and in this case I don't care anymore about the print. – Leonardo Jan 30 '21 at 02:35
  • in link above there is code which redirects output to variable before using `%run` - maybe it can help – furas Jan 30 '21 at 02:44

0 Answers0