(self, text: Union[str, bytes])
Write text to stdout (and a file) and optionally flush.
Write text to stdout (and a file) and optionally flush.
Write text to stdout ( and a file ) and optionally flush .
def write(self, text: Union[str, bytes]) -> None:
        """Write text to stdout (and a file) and optionally flush."""
        if isinstance(text, bytes):
            text = text.decode()
        if len(text) == 0: # workaround for a bug in VSCode debugger: sys.stdout.write(''); sys.stdout.flush() => crash
            return

        if self.file is not None:
            self.file.write(text)

        self.stdout.write(text)

        if self.should_flush:
            self.flush()
def write ( self , text : Union [ str , bytes ] ) -> None : if isinstance ( text , bytes ) : text = text . decode ( ) if len ( text ) == 0 : # workaround for a bug in VSCode debugger: sys.stdout.write(''); sys.stdout.flush() => crash return if self . file is not None : self . file . write ( text ) self . stdout . write ( text ) if self . should_flush : self . flush ( )