def subnets(self, prefixlen_diff=<NUM_LIT:1>, new_prefix=None):
if self._prefixlen == self._max_prefixlen:<EOL><INDENT>yield self<EOL>return<EOL><DEDENT>if new_prefix is not None:<EOL><INDENT>if new_prefix < self._prefixlen:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>if prefixlen_diff != <NUM_LIT:1>:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>prefixlen_diff = new_prefix - self._prefixlen<EOL><DEDENT>if prefixlen_diff < <NUM_LIT:0>:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>new_prefixlen = self._prefixlen + prefixlen_diff<EOL>if new_prefixlen > self._max_prefixlen:<EOL><INDENT>raise ValueError(<EOL>'<STR_LIT>' % (<EOL>new_prefixlen, self))<EOL><DEDENT>start = int(self.network_address)<EOL>end = int(self.broadcast_address) + <NUM_LIT:1><EOL>step = (int(self.hostmask) + <NUM_LIT:1>) >> prefixlen_diff<EOL>for new_addr in _compat_range(start, end, step):<EOL><INDENT>current = self.__class__((new_addr, new_prefixlen))<EOL>yield current<EOL><DEDENT>
The subnets which join to make the current subnet.

        In the case that self contains only one IP
        (self._prefixlen == 32 for IPv4 or self._prefixlen == 128
        for IPv6), yield an iterator with just ourself.

        Args:
            prefixlen_diff: An integer, the amount the prefix length
              should be increased by. This should not be set if
              new_prefix is also set.
            new_prefix: The desired new prefix length. This must be a
              larger number (smaller prefix) than the existing prefix.
              This should not be set if prefixlen_diff is also set.

        Returns:
            An iterator of IPv(4|6) objects.

        Raises:
            ValueError: The prefixlen_diff is too small or too large.
                OR
            prefixlen_diff and new_prefix are both set or new_prefix
              is a smaller number than the current prefix (smaller
              number means a larger network)