docs: def _check_stream(self):
          """Determines which output stream (stdout, stderr, or custom) to use"""
          if self.stream:
  
              try:
                  supported = ('PYCHARM_HOSTED' in os.environ or
                               os.isatty(sys.stdout.fileno()))
  
              # a fix for IPython notebook "IOStream has no fileno."
              except(UnsupportedOperation):
                  supported = True
  
              else:
                  if self.stream is not None and hasattr(self.stream, 'write'):
                      self._stream_out = self.stream.write
                      self._stream_flush = self.stream.flush
  
              if supported:
                  if self.stream == 1:
                      self._stream_out = sys.stdout.write
                      self._stream_flush = sys.stdout.flush
                  elif self.stream == 2:
                      self._stream_out = sys.stderr.write
                      self._stream_flush = sys.stderr.flush
              else:
                  if self.stream is not None and hasattr(self.stream, 'write'):
                      self._stream_out = self.stream.write
                      self._stream_flush = self.stream.flush
                  else:
                      print('Warning: No valid output stream.')