class_docstr: context manager for capturing stdout/err
class_docstr_tok: ["context","manager","for","capturing","stdout\/err"]
code: def __enter__(self):
      from IPython.core.getipython import get_ipython
      from IPython.core.displaypub import CapturingDisplayPublisher
      from IPython.core.displayhook import CapturingDisplayHook
  
      self.sys_stdout = sys.stdout
      self.sys_stderr = sys.stderr
  
      if self.display:
          self.shell = get_ipython()
          if self.shell is None:
              self.save_display_pub = None
              self.display = False
  
      stdout = stderr = outputs = None
      if self.stdout:
          stdout = sys.stdout = StringIO()
      if self.stderr:
          stderr = sys.stderr = StringIO()
      if self.display:
          self.save_display_pub = self.shell.display_pub
          self.shell.display_pub = CapturingDisplayPublisher()
          outputs = self.shell.display_pub.outputs
          self.save_display_hook = sys.displayhook
          sys.displayhook = CapturingDisplayHook(
              shell=self.shell, outputs=outputs
          )
  
      return CapturedIO(stdout, stderr, outputs)
  
imports: from __future__ import print_function, absolute_import
  import sys
  from IPython.utils.py3compat import PY3
label_desc: Use image node_id 2 for calling the capture_output obj's underlying member method code with example usage: obj.__enter__() and returns: CapturedIO