'Emulate numeric objects through network aggregation'

def __add__(self, other):

    if (self._ipversion != other._ipversion):
        raise ValueError('Only    networks    with    the    same    IP    version    can    be    added.')
    if (self._prefixlen != other._prefixlen):
        raise ValueError('Only    networks    with    the    same    prefixlen    can    be    added.')
    if (self._prefixlen < 1):
        raise ValueError("Networks    with    a    prefixlen    longer    than    /1    can't    be    added.")
    if (self > other):
        return other.__add__(self)
    if ((other.int() - self[(-1)].int()) != 1):
        raise ValueError('Only    adjacent    networks    can    be    added    together.')
    ret = IP(self.int(), ipversion=self._ipversion)
    ret._prefixlen = (self.prefixlen() - 1)
    if (not _checkNetaddrWorksWithPrefixlen(ret.ip, ret._prefixlen, ret._ipversion)):
        raise ValueError(('The    resulting    %s    has    invalid    prefix    length    (%s)' % (repr(ret), ret._prefixlen)))
    return ret
