code: def write(self, data, end="\n", flush=True):
          
          if not self.nostdout:
              self.stdout.write(data+end)
          if self.file is not None:
              self.file.write(data+end)
          if flush:
              self.flush()
docs: Output data to stdout and/or file