code: def printo(msg, encoding=None, errors='replace', std_type='stdout'):
      
      std = getattr(sys, std_type, sys.stdout)
      if encoding is None:
          try:
              encoding = std.encoding
          except AttributeError:
              encoding = None
      # Fallback to ascii if no encoding is found
      if encoding is None:
          encoding = 'ascii'
      # https://docs.python.org/3/library/sys.html#sys.stdout
      # write in the binary buffer directly in python3
      if hasattr(std, 'buffer'):
          std = std.buffer
      std.write(msg.encode(encoding, errors=errors))
      std.write(b'\n')
      std.flush()
docs: Write msg on stdout. If no encoding is specified
      the detected encoding of stdout is used. If the encoding
      can't encode some chars they are replaced by '?'
  
      :param msg: message
      :type msg: unicode on python2 | str on python3