Package netaddr :: Module address :: Class IP
[frames] | no frames]

Class IP

source code

object --+    
         |    
      Addr --+
             |
            IP

A class whose objects represent Internet Protocol network addresses that can be either IPv4 or IPv6.

Instance Methods
 
__init__(self, addr, addr_type=0)
Constructor.
source code
 
is_netmask(self)
Returns True if this addr is a mask that would return a host id, False otherwise.
source code
 
prefixlen(self)
Returns the number of bits set to 1 if this address is a netmask, zero otherwise.
source code
 
reverse_dns(self)
Returns the reverse DNS lookup string for this IP address.
source code
 
is_hostmask(self)
Returns True if this address is a mask that would return a network id, False otherwise.
source code

Inherited from Addr: __eq__, __ge__, __getitem__, __gt__, __hex__, __iadd__, __int__, __isub__, __iter__, __le__, __len__, __long__, __lt__, __setitem__, __str__, bits, setvalue

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__

Properties

Inherited from object: __class__

Method Details

__init__(self, addr, addr_type=0)
(Constructor)

source code 

Constructor.

addr - the string form of a IPv4 or IPv6 address, or a network byte order int/long value.

addr_type - (optional) the IP address type (AT_INET or AT_INET6). If addr is an int or long, this argument becomes mandatory.

Overrides: object.__init__