Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to silence a cell in the notebook #1863

Closed
Krastanov opened this issue Jun 6, 2012 · 4 comments · Fixed by #1870
Closed

Ability to silence a cell in the notebook #1863

Krastanov opened this issue Jun 6, 2012 · 4 comments · Fixed by #1870
Labels
Milestone

Comments

@Krastanov
Copy link

There are some functions in scipy that do not provide a way to silence them and they always pollute stdout with useless information. Usually I would just redirect sys.stdout, however this causes the notebook to hang.

Can a magic %noprint be provided in order to silence the stdout?

Or another option will be to have toggle stdout next to toggle output in the cell menu?

What can be used as a workaround?

@fperez
Copy link
Member

fperez commented Jun 6, 2012

It's a reasonable wishlist item, but nothing exists out of the box for it, I'm afraid.The one thing that's in the wings and that will help quite a bit with noisy output is #1825, which at least will contain the noise into a scrollable area rather than making a huge mess. But it's still not a toggle for all stdout.

@Krastanov
Copy link
Author

In the meantime I suppose I will just use different cells for the noisy command and the command producing the output/plot.

@minrk
Copy link
Member

minrk commented Jun 6, 2012

A cell magic that captures stdout/err, like I do in some parallel tests might be useful.

If you want to actually discard just stdout, you can use clear_output(stdout=True, stderr=False, outputs=False) at the end of your cell. This doesn't prevent it from displaying as it arrives, but it does clean it up at the end.

@minrk
Copy link
Member

minrk commented Jun 7, 2012

See #1870

@fperez fperez closed this as completed in 024e384 Jun 11, 2012
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this issue Nov 3, 2014
New `%%capture` cell magic captures stdout/err while running a cell.

Uses `capture_output()` context manager, moved to utils.io from IPython.parallel testing utilities, where it originated.

The caputre objects can be printed as a string, case in which they display the captured stdout, which is also available as `.stdout`.  The captured stderr, if any, is in a `.stderr` attribute.  A `.show()` method can be called to quickly print both, with stderr being correctly printed to the sys.stderr stream (so the notebook displays it with red highlighting).

closes ipython#1863
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants