title: Log results in Jupyter notebook and shell at the same time
body: <p>I have place a code snnipet at <code>~/.ipython/profile_default/startup</code> that redirects the output of a print statement that is executed on the Jupyter notebook to the cell, which is basically the following.</p>
  <pre><code>sys.stdout = open(1,'w')
  </code></pre>
  <p>The problem with this is that the the result of the print within the Jupyter notebook is never shown again, it is only redirected to the <a href="https://i.stack.imgur.com/td3RY.png" rel="nofollow noreferrer">shell</a> and it is not shown in the <a href="https://i.stack.imgur.com/07eJa.png" rel="nofollow noreferrer">notebook</a>.</p>
  <p>How I could send the result to the shell but also keep the result shown in the Jupyter notebook?</p>
  <p>Many thanks for the help.</p>