Warning
This documentation is for an old version of IPython. You can find docs for newer versions here.
Module: utils.capture
¶
IO capturing utilities.
3 Classes¶
-
class
IPython.utils.capture.
RichOutput
(source='', data=None, metadata=None)¶ Bases:
object
-
__init__
(source='', data=None, metadata=None)¶
-
-
class
IPython.utils.capture.
CapturedIO
(stdout, stderr, outputs=None)¶ Bases:
object
Simple object for containing captured stdout/err and rich display StringIO objects
Each instance c has three attributes:
c.stdout
: standard output as a stringc.stderr
: standard error as a stringc.outputs
: a list of rich display outputs
Additionally, there’s a
c.show()
method which will print all of the above in the same order, and can be invoked simply viac()
.-
__init__
(stdout, stderr, outputs=None)¶
-
outputs
¶ A list of the captured rich display outputs, if any.
If you have a CapturedIO object
c
, these can be displayed in IPython using:from IPython.display import display for o in c.outputs: display(o)
-
show
()¶ write my output to sys.stdout/err as appropriate
-
stderr
¶ Captured standard error
-
stdout
¶ Captured standard output