def __init__(self, file_or_name, mode="<STR_LIT:w>", channel='<STR_LIT>'):
if channel not in ['<STR_LIT>', '<STR_LIT>']:<EOL><INDENT>raise ValueError('<STR_LIT>' % channel)<EOL><DEDENT>if hasattr(file_or_name, '<STR_LIT>') and hasattr(file_or_name, '<STR_LIT>'):<EOL><INDENT>self.file = file_or_name<EOL><DEDENT>else:<EOL><INDENT>self.file = open(file_or_name, mode)<EOL><DEDENT>self.channel = channel<EOL>self.ostream = getattr(sys, channel)<EOL>setattr(sys, channel, self)<EOL>self._closed = False<EOL>
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']