Package netaddr :: Package ip :: Class IPRange
[hide private]
[frames] | no frames]

Class IPRange

object --+    
         |    
    BaseIP --+
             |
            IPRange
Known Subclasses:

An arbitrary IPv4 or IPv6 address range.

Formed from a lower and upper bound IP address. The upper bound IP cannot be numerically smaller than the lower bound and the IP version of both must match.

Instance Methods [hide private]
 
__contains__(self, other)
Returns: True if other falls within the boundary of this one, False otherwise.
 
__getitem__(self, index)
Returns: The IP address(es) in this IPRange object referenced by index or slice.
 
__init__(self, start, end)
Constructor.
 
__iter__(self)
Returns: An iterator providing access to all IPAddress objects within range represented by this IPRange object.
 
__len__(self)
Returns: the number of IP addresses in this IPRange.
 
__nonzero__(self)
IPRange objects always represent a sequence of at least one IP address and are therefore always True in the boolean context.
 
__repr__(self)
Returns: Python statement to create an equivalent object
 
__str__(self)
Returns: this IPRange in a common representational format.
 
cidrs(self)
The list of CIDR addresses found within the lower and upper bound addresses of this IPRange.
 
key(self)
Returns: A key tuple used to uniquely identify this IPRange.
 
sort_key(self)
Returns: A key tuple used to compare and sort this IPRange correctly.

Inherited from object: __delattr__, __format__, __getattribute__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

    Inherited from BaseIP
 
__eq__(self, other)
Returns: True if this IPAddress or IPNetwork object is equivalent to other, False otherwise.
 
__ge__(self, other)
Returns: True if this IPAddress or IPNetwork object is greater than or equal to other, False otherwise.
 
__gt__(self, other)
Returns: True if this IPAddress or IPNetwork object is greater than other, False otherwise.
 
__hash__(self)
Returns: A hash value uniquely indentifying this IP object.
 
__le__(self, other)
Returns: True if this IPAddress or IPNetwork object is less than or equal to other, False otherwise.
 
__lt__(self, other)
Returns: True if this IPAddress or IPNetwork object is less than other, False otherwise.
 
__ne__(self, other)
Returns: True if this IPAddress or IPNetwork object is not equivalent to other, False otherwise.
 
is_ipv4_compat(self)
Returns: True if this IP is IPv4-mapped IPv6 address, False otherwise.
 
is_ipv4_mapped(self)
Returns: True if this IP is IPv4-compatible IPv6 address, False otherwise.
 
is_link_local(self)
Returns: True if this IP is link-local address False otherwise.
 
is_loopback(self)
Returns: True if this IP is loopback address (not for network transmission), False otherwise.
 
is_multicast(self)
Returns: True if this IP is multicast, False otherwise
 
is_private(self)
Returns: True if this IP is for internal/private use only (i.e.
 
is_reserved(self)
Returns: True if this IP is in IANA reserved range, False otherwise.
 
is_unicast(self)
Returns: True if this IP is unicast, False otherwise
Properties [hide private]
  first
The integer value of first IP address in this IPRange object.
  last
The integer value of last IP address in this IPRange object.
  size
The number of IP addresses within this IPRange.

Inherited from object: __class__

    Inherited from BaseIP
  info
A record dict containing IANA registration details for this IP address if available, None otherwise.
  version
the IP protocol version represented by this IP object.
Method Details [hide private]

__contains__(self, other)
(In operator)

 
Parameters:
Returns:
True if other falls within the boundary of this one, False otherwise.

__getitem__(self, index)
(Indexing operator)

 
Returns:
The IP address(es) in this IPRange object referenced by index or slice. As slicing can produce large sequences of objects an iterator is returned instead of the more usual list.

__init__(self, start, end)
(Constructor)

 

Constructor.

Parameters:
  • start - an IPv4 or IPv6 address that forms the lower boundary of this IP range.
  • end - an IPv4 or IPv6 address that forms the upper boundary of this IP range.
Overrides: object.__init__

__iter__(self)

 
Returns:
An iterator providing access to all IPAddress objects within range represented by this IPRange object.

__len__(self)
(Length operator)

 
Returns:
the number of IP addresses in this IPRange. Raises an IndexError if size > sys.maxint (a Python 2.x limitation). Use the .size property for subnets of any size.

__repr__(self)
(Representation operator)

 

repr(x)

Returns:
Python statement to create an equivalent object
Overrides: object.__repr__

__str__(self)
(Informal representation operator)

 

str(x)

Returns:
this IPRange in a common representational format.
Overrides: object.__str__

key(self)

 
Returns:
A key tuple used to uniquely identify this IPRange.
Overrides: BaseIP.key

sort_key(self)

 
Returns:
A key tuple used to compare and sort this IPRange correctly.
Overrides: BaseIP.sort_key

Property Details [hide private]

first

The integer value of first IP address in this IPRange object.

Get Method:
unreachable.first(self) - The integer value of first IP address in this IPRange object.

last

The integer value of last IP address in this IPRange object.

Get Method:
unreachable.last(self) - The integer value of last IP address in this IPRange object.

size

The number of IP addresses within this IPRange.

Get Method:
unreachable.size(self) - The number of IP addresses within this IPRange.