def set_value(self, label, value, type=None):
        """Attempt to set one of the key's named values. If type is
        None, then if the value already exists under the key its
        current type is assumed; otherwise a guess is made at
        the datatype as follows:

        * If the value is an int, use DWORD
        * If the value is a list, use MULTI_SZ
        * If the value has an even number of percent signs, use EXPAND_SZ
        * Otherwise, use REG_SZ

        This is a very naive approach, and will falter if, for example,
        a string is passed which can be converted into a number, or a string
        with 2 percent signs which don't refer to an env var.
        """
        def _guess_type(value):
            try:
                int(value)
            except (ValueError, __HOLE__):
                pass
            else:
                return REGISTRY_VALUE_TYPE.REG_DWORD
            if isinstance(value, list):
                return REGISTRY_VALUE_TYPE.REG_MULTI_SZ
            value = unicode(value)
            if "%" in value and value.count("%") % 2 == 0:
                return REGISTRY_VALUE_TYPE.REG_EXPAND_SZ
            return REGISTRY_VALUE_TYPE.REG_SZ

        type = REGISTRY_VALUE_TYPE.constant(type)
        if type is None:
            try:
                _, type = wrapped(win32api.RegQueryValueEx, self.pyobject(), label)
            except exc.x_not_found:
                type = _guess_type(value)
        wrapped(win32api.RegSetValueEx, self.pyobject(), label, 0, type, value)
dataset/ETHPy150Open tjguk/winsys/winsys/registry.py/Registry.set_value