code: def getoutputencoding(stream=None):
      
      if stream is None:
          stream = sys.stdout
      encoding = stream.encoding
      if not encoding:
          encoding = getpreferredencoding()
      return encoding
docs: Return preferred encoding for writing to ``stream``.
  
      ``stream`` defaults to sys.stdout.