'Called to implement evaluation of self[key].
>>> ip=IP(\'127.0.0.0/30\')
>>> for x in ip:
...  print(repr(x))
IP(\'127.0.0.0\')
IP(\'127.0.0.1\')
IP(\'127.0.0.2\')
IP(\'127.0.0.3\')
>>> ip[2]
IP(\'127.0.0.2\')
>>> ip[-1]
IP(\'127.0.0.3\')'

def __getitem__(self, key):

    if isinstance(key, slice):
        return [(self.ip + int(x)) for x in xrange(*key.indices(len(self)))]
    if (not isinstance(key, INT_TYPES)):
        raise TypeError
    if (key < 0):
        if (abs(key) <= self.len()):
            key = (self.len() - abs(key))
        else:
            raise IndexError
    elif (key >= self.len()):
        raise IndexError
    return (self.ip + int(key))
