class_docstr: A class to duplicate an output stream to stdout/err.
  
  This works in a manner very similar to the Unix 'tee' command.
  
  When the object is closed or deleted, it closes the original file given to
  it for duplication.
class_docstr_tok: ["A","class","to","duplicate","an","output","stream","to","stdout\/err",".","This","works","in","a","manner","very","similar","to","the","Unix","'tee","'","command",".","When","the","object","is","closed","or","deleted",",","it","closes","the","original","file","given","to","it","for","duplication","."]
docstr: Construct a new Tee object.
  
  Parameters
  ----------
  file_or_name : filename or open filehandle (writable)
      File that will be duplicated
  mode : optional, valid mode for open().
      If a filename was give, open with this mode.
  channel : str, one of ['stdout', 'stderr']
docstr_tok: ["Construct","a","new","Tee","object",".","Parameters","--","--","--","--","--","file_or_name",":","filename","or","open","filehandle","(","writable",")","File","that","will","be","duplicated","mode",":","optional",",","valid","mode","for","open","(",")",".","If","a","filename","was","give",",","open","with","this","mode",".","channel",":","str",",","one","of","[","'stdout","'",",","'stderr","'","]"]
code: def __init__(self, file_or_name, mode="w", channel="stdout"):
      """Construct a new Tee object.
  
      Parameters
      ----------
      file_or_name : filename or open filehandle (writable)
          File that will be duplicated
      mode : optional, valid mode for open().
          If a filename was give, open with this mode.
      channel : str, one of ['stdout', 'stderr']
      """
      if channel not in ["stdout", "stderr"]:
          raise ValueError("Invalid channel spec %s" % channel)
  
      if hasattr(file_or_name, "write") and hasattr(
          file_or_name, "seek"
      ):
          self.file = file_or_name
      else:
          encoding = None if "b" in mode else "utf-8"
          self.file = open(file_or_name, mode, encoding=encoding)
      self.channel = channel
      self.ostream = getattr(sys, channel)
      setattr(sys, channel, self)
      self._closed = False
  
file_path: catboost/contrib/python/ipython/py3/IPython/utils/io.py
imports: import atexit
  import os
  import sys
  import tempfile
  from pathlib import Path
  from warnings import warn
  from IPython.utils.decorators import undoc
  from .capture import CapturedIO, capture_output
label_desc: Use image node_id 1 to create a new Tee object from inherited base classes: object with example: obj = Tee(file_or_name, mode, channel)