ipython/ipython — pull request #1870 by minrk (2012-06-07 00:03:10+00:00)
Title: add %%capture for capturing stdout/err

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.

Default behavior: discards stdout/err
Optionally stores stdout/err in variables

Possible alternate behavior: only store the single CapturedIO object in a variable, so both outputs are accessible as io.stdout / io.stderr, rather than having to store them separately.

If we don't want the magic and/or notebook, then I'm fine discarding them, but the capture_output context manager probably does belong in utils.io.