code: def write(address, buf):
          
          if sys.version_info.major >= 3:
              if type(buf) is str:
                  buf = bytes(map(ord, buf))
              else:
                  buf = bytes(buf)
          else:
              if type(buf) is not str:
                  buf = ''.join([chr(x) for x in buf])
          arr = create_string_buffer(buf, len(buf))
          return i2c_msg(
              addr=address, flags=0, len=len(arr),
              buf=arr)
docs: Prepares an i2c write transaction.
  
          :param address: Slave address.
          :type address: int
          :param buf: Bytes to write. Either list of values or str.
          :type buf: list
          :return: New :py:class:`i2c_msg` instance for write operation.
          :rtype: :py:class:`i2c_msg`