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

def virtManager::IPy::IPint::__getitem__ (   self,
  key 
)

Called to implement evaluation of self[key].

>>> ip=IP('127.0.0.0/30')
>>> for x in ip:
...  print hex(x.int())
...
0x7F000000L
0x7F000001L
0x7F000002L
0x7F000003L
>>> hex(ip[2].int())
'0x7F000002L'
>>> hex(ip[-1].int())
'0x7F000003L'

Reimplemented in virtManager::IPy::IP.

Definition at line 621 of file IPy.py.

00621                               :
        """Called to implement evaluation of self[key].
        
        >>> ip=IP('127.0.0.0/30')
        >>> for x in ip:
        ...  print hex(x.int())
        ...
        0x7F000000L
        0x7F000001L
        0x7F000002L
        0x7F000003L
        >>> hex(ip[2].int())
        '0x7F000002L'
        >>> hex(ip[-1].int())
        '0x7F000003L'
        """

        if type(key) != types.IntType and type(key) != types.LongType:
            raise TypeError
        if abs(key) >= self.len():
            raise IndexError
        if key < 0:
            key = self.len() - abs(key)

        return self.ip + long(key)

    

    def __contains__(self, item):


Generated by  Doxygen 1.6.0   Back to index