Logo Search packages:      
Sourcecode: virt-manager version File versions  Download package

def virtManager::IPy::IPint::len (   self  ) 

Return the length of an subnet.

>>> print IP('195.185.1.0/28').len()
16
>>> print IP('195.185.1.0/24').len()
256

Definition at line 590 of file IPy.py.

00590                  :
        """Return the length of an subnet.

        >>> print IP('195.185.1.0/28').len()
        16
        >>> print IP('195.185.1.0/24').len()
        256
        """

        if self._ipversion == 4:
            locallen = 32 - self._prefixlen
        elif self._ipversion == 6:
            locallen = 128 - self._prefixlen
        else:
            raise ValueError, "only IPv4 and IPv6 supported"

        return 2L ** locallen 


    def __len__(self):


Generated by  Doxygen 1.6.0   Back to index