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

def virtManager::IPy::IPint::strBin (   self,
  wantprefixlen = None 
)

Return a string representation as a binary value.

>>> print IP('127.0.0.1').strBin()
01111111000000000000000000000001

Definition at line 390 of file IPy.py.

00390                                           : 
        """Return a string representation as a binary value.

        >>> print IP('127.0.0.1').strBin()
        01111111000000000000000000000001
        """


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

        if self.WantPrefixLen == None and wantprefixlen == None:
            wantprefixlen = 0
        ret = _intToBin(self.ip)
        return  '0' * (bits - len(ret)) + ret + self._printPrefix(wantprefixlen)


Generated by  Doxygen 1.6.0   Back to index