code: def set(self, value):
          
  
          if not isinstance(value, str_cls):
              raise TypeError(unwrap(
                  '''
                  %s value must be a unicode string, not %s
                  ''',
                  type_name(self),
                  type_name(value)
              ))
  
          original_value = value
  
          has_cidr = value.find('/') != -1
          cidr = 0
          if has_cidr:
              parts = value.split('/', 1)
              value = parts[0]
              cidr = int(parts[1])
              if cidr < 0:
                  raise ValueError(unwrap(
                      '''
                      %s value contains a CIDR range less than 0
                      ''',
                      type_name(self)
                  ))
  
          if value.find(':') != -1:
              family = socket.AF_INET6
              if cidr > 128:
                  raise ValueError(unwrap(
                      '''
                      %s value contains a CIDR range bigger than 128, the maximum
                      value for an IPv6 address
                      ''',
                      type_name(self)
                  ))
              cidr_size = 128
          else:
              family = socket.AF_INET
              if cidr > 32:
                  raise ValueError(unwrap(
                      '''
                      %s value contains a CIDR range bigger than 32, the maximum
                      value for an IPv4 address
                      ''',
                      type_name(self)
                  ))
              cidr_size = 32
  
          cidr_bytes = b''
          if has_cidr:
              cidr_mask = '1' * cidr
              cidr_mask += '0' * (cidr_size - len(cidr_mask))
              cidr_bytes = int_to_bytes(int(cidr_mask, 2))
              cidr_bytes = (b'\x00' * ((cidr_size // 8) - len(cidr_bytes))) + cidr_bytes
  
          self._native = original_value
          self.contents = inet_pton(family, value) + cidr_bytes
          self._bytes = self.contents
          self._header = None
          if self._trailer != b'':
              self._trailer = b''
docs: Sets the value of the object
  
          :param value:
              A unicode string containing an IPv4 address, IPv4 address with CIDR,
              an IPv6 address or IPv6 address with CIDR