doc_content stringlengths 1 386k | doc_id stringlengths 5 188 |
|---|---|
ip
The address (IPv4Address) without network information. >>> interface = IPv4Interface('192.0.2.5/24')
>>> interface.ip
IPv4Address('192.0.2.5') | python.library.ipaddress#ipaddress.IPv4Interface.ip |
network
The network (IPv4Network) this interface belongs to. >>> interface = IPv4Interface('192.0.2.5/24')
>>> interface.network
IPv4Network('192.0.2.0/24') | python.library.ipaddress#ipaddress.IPv4Interface.network |
with_hostmask
A string representation of the interface with the network as a host mask. >>> interface = IPv4Interface('192.0.2.5/24')
>>> interface.with_hostmask
'192.0.2.5/0.0.0.255' | python.library.ipaddress#ipaddress.IPv4Interface.with_hostmask |
with_netmask
A string representation of the interface with the network as a net mask. >>> interface = IPv4Interface('192.0.2.5/24')
>>> interface.with_netmask
'192.0.2.5/255.255.255.0' | python.library.ipaddress#ipaddress.IPv4Interface.with_netmask |
with_prefixlen
A string representation of the interface with the mask in prefix notation. >>> interface = IPv4Interface('192.0.2.5/24')
>>> interface.with_prefixlen
'192.0.2.5/24' | python.library.ipaddress#ipaddress.IPv4Interface.with_prefixlen |
class ipaddress.IPv4Network(address, strict=True)
Construct an IPv4 network definition. address can be one of the following:
A string consisting of an IP address and an optional mask, separated by a slash (/). The IP address is the network address, and the mask can be either a single number, which means it’s a prefix, or a string representation of an IPv4 address. If it’s the latter, the mask is interpreted as a net mask if it starts with a non-zero field, or as a host mask if it starts with a zero field, with the single exception of an all-zero mask which is treated as a net mask. If no mask is provided, it’s considered to be /32. For example, the following address specifications are equivalent: 192.168.1.0/24, 192.168.1.0/255.255.255.0 and 192.168.1.0/0.0.0.255. An integer that fits into 32 bits. This is equivalent to a single-address network, with the network address being address and the mask being /32. An integer packed into a bytes object of length 4, big-endian. The interpretation is similar to an integer address. A two-tuple of an address description and a netmask, where the address description is either a string, a 32-bits integer, a 4-bytes packed integer, or an existing IPv4Address object; and the netmask is either an integer representing the prefix length (e.g. 24) or a string representing the prefix mask (e.g. 255.255.255.0). An AddressValueError is raised if address is not a valid IPv4 address. A NetmaskValueError is raised if the mask is not valid for an IPv4 address. If strict is True and host bits are set in the supplied address, then ValueError is raised. Otherwise, the host bits are masked out to determine the appropriate network address. Unless stated otherwise, all network methods accepting other network/address objects will raise TypeError if the argument’s IP version is incompatible to self. Changed in version 3.5: Added the two-tuple form for the address constructor parameter.
version
max_prefixlen
Refer to the corresponding attribute documentation in IPv4Address.
is_multicast
is_private
is_unspecified
is_reserved
is_loopback
is_link_local
These attributes are true for the network as a whole if they are true for both the network address and the broadcast address.
network_address
The network address for the network. The network address and the prefix length together uniquely define a network.
broadcast_address
The broadcast address for the network. Packets sent to the broadcast address should be received by every host on the network.
hostmask
The host mask, as an IPv4Address object.
netmask
The net mask, as an IPv4Address object.
with_prefixlen
compressed
exploded
A string representation of the network, with the mask in prefix notation. with_prefixlen and compressed are always the same as str(network). exploded uses the exploded form the network address.
with_netmask
A string representation of the network, with the mask in net mask notation.
with_hostmask
A string representation of the network, with the mask in host mask notation.
num_addresses
The total number of addresses in the network.
prefixlen
Length of the network prefix, in bits.
hosts()
Returns an iterator over the usable hosts in the network. The usable hosts are all the IP addresses that belong to the network, except the network address itself and the network broadcast address. For networks with a mask length of 31, the network address and network broadcast address are also included in the result. Networks with a mask of 32 will return a list containing the single host address. >>> list(ip_network('192.0.2.0/29').hosts())
[IPv4Address('192.0.2.1'), IPv4Address('192.0.2.2'),
IPv4Address('192.0.2.3'), IPv4Address('192.0.2.4'),
IPv4Address('192.0.2.5'), IPv4Address('192.0.2.6')]
>>> list(ip_network('192.0.2.0/31').hosts())
[IPv4Address('192.0.2.0'), IPv4Address('192.0.2.1')]
>>> list(ip_network('192.0.2.1/32').hosts())
[IPv4Address('192.0.2.1')]
overlaps(other)
True if this network is partly or wholly contained in other or other is wholly contained in this network.
address_exclude(network)
Computes the network definitions resulting from removing the given network from this one. Returns an iterator of network objects. Raises ValueError if network is not completely contained in this network. >>> n1 = ip_network('192.0.2.0/28')
>>> n2 = ip_network('192.0.2.1/32')
>>> list(n1.address_exclude(n2))
[IPv4Network('192.0.2.8/29'), IPv4Network('192.0.2.4/30'),
IPv4Network('192.0.2.2/31'), IPv4Network('192.0.2.0/32')]
subnets(prefixlen_diff=1, new_prefix=None)
The subnets that join to make the current network definition, depending on the argument values. prefixlen_diff is the amount our prefix length should be increased by. new_prefix is the desired new prefix of the subnets; it must be larger than our prefix. One and only one of prefixlen_diff and new_prefix must be set. Returns an iterator of network objects. >>> list(ip_network('192.0.2.0/24').subnets())
[IPv4Network('192.0.2.0/25'), IPv4Network('192.0.2.128/25')]
>>> list(ip_network('192.0.2.0/24').subnets(prefixlen_diff=2))
[IPv4Network('192.0.2.0/26'), IPv4Network('192.0.2.64/26'),
IPv4Network('192.0.2.128/26'), IPv4Network('192.0.2.192/26')]
>>> list(ip_network('192.0.2.0/24').subnets(new_prefix=26))
[IPv4Network('192.0.2.0/26'), IPv4Network('192.0.2.64/26'),
IPv4Network('192.0.2.128/26'), IPv4Network('192.0.2.192/26')]
>>> list(ip_network('192.0.2.0/24').subnets(new_prefix=23))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
raise ValueError('new prefix must be longer')
ValueError: new prefix must be longer
>>> list(ip_network('192.0.2.0/24').subnets(new_prefix=25))
[IPv4Network('192.0.2.0/25'), IPv4Network('192.0.2.128/25')]
supernet(prefixlen_diff=1, new_prefix=None)
The supernet containing this network definition, depending on the argument values. prefixlen_diff is the amount our prefix length should be decreased by. new_prefix is the desired new prefix of the supernet; it must be smaller than our prefix. One and only one of prefixlen_diff and new_prefix must be set. Returns a single network object. >>> ip_network('192.0.2.0/24').supernet()
IPv4Network('192.0.2.0/23')
>>> ip_network('192.0.2.0/24').supernet(prefixlen_diff=2)
IPv4Network('192.0.0.0/22')
>>> ip_network('192.0.2.0/24').supernet(new_prefix=20)
IPv4Network('192.0.0.0/20')
subnet_of(other)
Return True if this network is a subnet of other. >>> a = ip_network('192.168.1.0/24')
>>> b = ip_network('192.168.1.128/30')
>>> b.subnet_of(a)
True
New in version 3.7.
supernet_of(other)
Return True if this network is a supernet of other. >>> a = ip_network('192.168.1.0/24')
>>> b = ip_network('192.168.1.128/30')
>>> a.supernet_of(b)
True
New in version 3.7.
compare_networks(other)
Compare this network to other. In this comparison only the network addresses are considered; host bits aren’t. Returns either -1, 0 or 1. >>> ip_network('192.0.2.1/32').compare_networks(ip_network('192.0.2.2/32'))
-1
>>> ip_network('192.0.2.1/32').compare_networks(ip_network('192.0.2.0/32'))
1
>>> ip_network('192.0.2.1/32').compare_networks(ip_network('192.0.2.1/32'))
0
Deprecated since version 3.7: It uses the same ordering and comparison algorithm as “<”, “==”, and “>” | python.library.ipaddress#ipaddress.IPv4Network |
address_exclude(network)
Computes the network definitions resulting from removing the given network from this one. Returns an iterator of network objects. Raises ValueError if network is not completely contained in this network. >>> n1 = ip_network('192.0.2.0/28')
>>> n2 = ip_network('192.0.2.1/32')
>>> list(n1.address_exclude(n2))
[IPv4Network('192.0.2.8/29'), IPv4Network('192.0.2.4/30'),
IPv4Network('192.0.2.2/31'), IPv4Network('192.0.2.0/32')] | python.library.ipaddress#ipaddress.IPv4Network.address_exclude |
broadcast_address
The broadcast address for the network. Packets sent to the broadcast address should be received by every host on the network. | python.library.ipaddress#ipaddress.IPv4Network.broadcast_address |
compare_networks(other)
Compare this network to other. In this comparison only the network addresses are considered; host bits aren’t. Returns either -1, 0 or 1. >>> ip_network('192.0.2.1/32').compare_networks(ip_network('192.0.2.2/32'))
-1
>>> ip_network('192.0.2.1/32').compare_networks(ip_network('192.0.2.0/32'))
1
>>> ip_network('192.0.2.1/32').compare_networks(ip_network('192.0.2.1/32'))
0
Deprecated since version 3.7: It uses the same ordering and comparison algorithm as “<”, “==”, and “>” | python.library.ipaddress#ipaddress.IPv4Network.compare_networks |
compressed | python.library.ipaddress#ipaddress.IPv4Network.compressed |
exploded
A string representation of the network, with the mask in prefix notation. with_prefixlen and compressed are always the same as str(network). exploded uses the exploded form the network address. | python.library.ipaddress#ipaddress.IPv4Network.exploded |
hostmask
The host mask, as an IPv4Address object. | python.library.ipaddress#ipaddress.IPv4Network.hostmask |
hosts()
Returns an iterator over the usable hosts in the network. The usable hosts are all the IP addresses that belong to the network, except the network address itself and the network broadcast address. For networks with a mask length of 31, the network address and network broadcast address are also included in the result. Networks with a mask of 32 will return a list containing the single host address. >>> list(ip_network('192.0.2.0/29').hosts())
[IPv4Address('192.0.2.1'), IPv4Address('192.0.2.2'),
IPv4Address('192.0.2.3'), IPv4Address('192.0.2.4'),
IPv4Address('192.0.2.5'), IPv4Address('192.0.2.6')]
>>> list(ip_network('192.0.2.0/31').hosts())
[IPv4Address('192.0.2.0'), IPv4Address('192.0.2.1')]
>>> list(ip_network('192.0.2.1/32').hosts())
[IPv4Address('192.0.2.1')] | python.library.ipaddress#ipaddress.IPv4Network.hosts |
is_link_local
These attributes are true for the network as a whole if they are true for both the network address and the broadcast address. | python.library.ipaddress#ipaddress.IPv4Network.is_link_local |
is_loopback | python.library.ipaddress#ipaddress.IPv4Network.is_loopback |
is_multicast | python.library.ipaddress#ipaddress.IPv4Network.is_multicast |
is_private | python.library.ipaddress#ipaddress.IPv4Network.is_private |
is_reserved | python.library.ipaddress#ipaddress.IPv4Network.is_reserved |
is_unspecified | python.library.ipaddress#ipaddress.IPv4Network.is_unspecified |
max_prefixlen
Refer to the corresponding attribute documentation in IPv4Address. | python.library.ipaddress#ipaddress.IPv4Network.max_prefixlen |
netmask
The net mask, as an IPv4Address object. | python.library.ipaddress#ipaddress.IPv4Network.netmask |
network_address
The network address for the network. The network address and the prefix length together uniquely define a network. | python.library.ipaddress#ipaddress.IPv4Network.network_address |
num_addresses
The total number of addresses in the network. | python.library.ipaddress#ipaddress.IPv4Network.num_addresses |
overlaps(other)
True if this network is partly or wholly contained in other or other is wholly contained in this network. | python.library.ipaddress#ipaddress.IPv4Network.overlaps |
prefixlen
Length of the network prefix, in bits. | python.library.ipaddress#ipaddress.IPv4Network.prefixlen |
subnets(prefixlen_diff=1, new_prefix=None)
The subnets that join to make the current network definition, depending on the argument values. prefixlen_diff is the amount our prefix length should be increased by. new_prefix is the desired new prefix of the subnets; it must be larger than our prefix. One and only one of prefixlen_diff and new_prefix must be set. Returns an iterator of network objects. >>> list(ip_network('192.0.2.0/24').subnets())
[IPv4Network('192.0.2.0/25'), IPv4Network('192.0.2.128/25')]
>>> list(ip_network('192.0.2.0/24').subnets(prefixlen_diff=2))
[IPv4Network('192.0.2.0/26'), IPv4Network('192.0.2.64/26'),
IPv4Network('192.0.2.128/26'), IPv4Network('192.0.2.192/26')]
>>> list(ip_network('192.0.2.0/24').subnets(new_prefix=26))
[IPv4Network('192.0.2.0/26'), IPv4Network('192.0.2.64/26'),
IPv4Network('192.0.2.128/26'), IPv4Network('192.0.2.192/26')]
>>> list(ip_network('192.0.2.0/24').subnets(new_prefix=23))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
raise ValueError('new prefix must be longer')
ValueError: new prefix must be longer
>>> list(ip_network('192.0.2.0/24').subnets(new_prefix=25))
[IPv4Network('192.0.2.0/25'), IPv4Network('192.0.2.128/25')] | python.library.ipaddress#ipaddress.IPv4Network.subnets |
subnet_of(other)
Return True if this network is a subnet of other. >>> a = ip_network('192.168.1.0/24')
>>> b = ip_network('192.168.1.128/30')
>>> b.subnet_of(a)
True
New in version 3.7. | python.library.ipaddress#ipaddress.IPv4Network.subnet_of |
supernet(prefixlen_diff=1, new_prefix=None)
The supernet containing this network definition, depending on the argument values. prefixlen_diff is the amount our prefix length should be decreased by. new_prefix is the desired new prefix of the supernet; it must be smaller than our prefix. One and only one of prefixlen_diff and new_prefix must be set. Returns a single network object. >>> ip_network('192.0.2.0/24').supernet()
IPv4Network('192.0.2.0/23')
>>> ip_network('192.0.2.0/24').supernet(prefixlen_diff=2)
IPv4Network('192.0.0.0/22')
>>> ip_network('192.0.2.0/24').supernet(new_prefix=20)
IPv4Network('192.0.0.0/20') | python.library.ipaddress#ipaddress.IPv4Network.supernet |
supernet_of(other)
Return True if this network is a supernet of other. >>> a = ip_network('192.168.1.0/24')
>>> b = ip_network('192.168.1.128/30')
>>> a.supernet_of(b)
True
New in version 3.7. | python.library.ipaddress#ipaddress.IPv4Network.supernet_of |
version | python.library.ipaddress#ipaddress.IPv4Network.version |
with_hostmask
A string representation of the network, with the mask in host mask notation. | python.library.ipaddress#ipaddress.IPv4Network.with_hostmask |
with_netmask
A string representation of the network, with the mask in net mask notation. | python.library.ipaddress#ipaddress.IPv4Network.with_netmask |
with_prefixlen | python.library.ipaddress#ipaddress.IPv4Network.with_prefixlen |
class ipaddress.IPv6Address(address)
Construct an IPv6 address. An AddressValueError is raised if address is not a valid IPv6 address. The following constitutes a valid IPv6 address:
A string consisting of eight groups of four hexadecimal digits, each group representing 16 bits. The groups are separated by colons. This describes an exploded (longhand) notation. The string can also be compressed (shorthand notation) by various means. See RFC 4291 for details. For example, "0000:0000:0000:0000:0000:0abc:0007:0def" can be compressed to "::abc:7:def". Optionally, the string may also have a scope zone ID, expressed with a suffix %scope_id. If present, the scope ID must be non-empty, and may not contain %. See RFC 4007 for details. For example, fe80::1234%1 might identify address fe80::1234 on the first link of the node. An integer that fits into 128 bits. An integer packed into a bytes object of length 16, big-endian. >>> ipaddress.IPv6Address('2001:db8::1000')
IPv6Address('2001:db8::1000')
>>> ipaddress.IPv6Address('ff02::5678%1')
IPv6Address('ff02::5678%1')
compressed
The short form of the address representation, with leading zeroes in groups omitted and the longest sequence of groups consisting entirely of zeroes collapsed to a single empty group. This is also the value returned by str(addr) for IPv6 addresses.
exploded
The long form of the address representation, with all leading zeroes and groups consisting entirely of zeroes included. For the following attributes and methods, see the corresponding documentation of the IPv4Address class:
packed
reverse_pointer
version
max_prefixlen
is_multicast
is_private
is_global
is_unspecified
is_reserved
is_loopback
is_link_local
New in version 3.4: is_global
is_site_local
True if the address is reserved for site-local usage. Note that the site-local address space has been deprecated by RFC 3879. Use is_private to test if this address is in the space of unique local addresses as defined by RFC 4193.
ipv4_mapped
For addresses that appear to be IPv4 mapped addresses (starting with ::FFFF/96), this property will report the embedded IPv4 address. For any other address, this property will be None.
scope_id
For scoped addresses as defined by RFC 4007, this property identifies the particular zone of the address’s scope that the address belongs to, as a string. When no scope zone is specified, this property will be None.
sixtofour
For addresses that appear to be 6to4 addresses (starting with 2002::/16) as defined by RFC 3056, this property will report the embedded IPv4 address. For any other address, this property will be None.
teredo
For addresses that appear to be Teredo addresses (starting with 2001::/32) as defined by RFC 4380, this property will report the embedded (server, client) IP address pair. For any other address, this property will be None. | python.library.ipaddress#ipaddress.IPv6Address |
compressed | python.library.ipaddress#ipaddress.IPv6Address.compressed |
exploded | python.library.ipaddress#ipaddress.IPv6Address.exploded |
ipv4_mapped
For addresses that appear to be IPv4 mapped addresses (starting with ::FFFF/96), this property will report the embedded IPv4 address. For any other address, this property will be None. | python.library.ipaddress#ipaddress.IPv6Address.ipv4_mapped |
is_global | python.library.ipaddress#ipaddress.IPv6Address.is_global |
is_link_local
New in version 3.4: is_global | python.library.ipaddress#ipaddress.IPv6Address.is_link_local |
is_loopback | python.library.ipaddress#ipaddress.IPv6Address.is_loopback |
is_multicast | python.library.ipaddress#ipaddress.IPv6Address.is_multicast |
is_private | python.library.ipaddress#ipaddress.IPv6Address.is_private |
is_reserved | python.library.ipaddress#ipaddress.IPv6Address.is_reserved |
is_site_local
True if the address is reserved for site-local usage. Note that the site-local address space has been deprecated by RFC 3879. Use is_private to test if this address is in the space of unique local addresses as defined by RFC 4193. | python.library.ipaddress#ipaddress.IPv6Address.is_site_local |
is_unspecified | python.library.ipaddress#ipaddress.IPv6Address.is_unspecified |
max_prefixlen | python.library.ipaddress#ipaddress.IPv6Address.max_prefixlen |
packed | python.library.ipaddress#ipaddress.IPv6Address.packed |
reverse_pointer | python.library.ipaddress#ipaddress.IPv6Address.reverse_pointer |
scope_id
For scoped addresses as defined by RFC 4007, this property identifies the particular zone of the address’s scope that the address belongs to, as a string. When no scope zone is specified, this property will be None. | python.library.ipaddress#ipaddress.IPv6Address.scope_id |
sixtofour
For addresses that appear to be 6to4 addresses (starting with 2002::/16) as defined by RFC 3056, this property will report the embedded IPv4 address. For any other address, this property will be None. | python.library.ipaddress#ipaddress.IPv6Address.sixtofour |
teredo
For addresses that appear to be Teredo addresses (starting with 2001::/32) as defined by RFC 4380, this property will report the embedded (server, client) IP address pair. For any other address, this property will be None. | python.library.ipaddress#ipaddress.IPv6Address.teredo |
version | python.library.ipaddress#ipaddress.IPv6Address.version |
IPv6Address.__format__(fmt)
Refer to the corresponding method documentation in IPv4Address. New in version 3.9. | python.library.ipaddress#ipaddress.IPv6Address.__format__ |
class ipaddress.IPv6Interface(address)
Construct an IPv6 interface. The meaning of address is as in the constructor of IPv6Network, except that arbitrary host addresses are always accepted. IPv6Interface is a subclass of IPv6Address, so it inherits all the attributes from that class. In addition, the following attributes are available:
ip
network
with_prefixlen
with_netmask
with_hostmask
Refer to the corresponding attribute documentation in IPv4Interface. | python.library.ipaddress#ipaddress.IPv6Interface |
ip | python.library.ipaddress#ipaddress.IPv6Interface.ip |
network | python.library.ipaddress#ipaddress.IPv6Interface.network |
with_hostmask
Refer to the corresponding attribute documentation in IPv4Interface. | python.library.ipaddress#ipaddress.IPv6Interface.with_hostmask |
with_netmask | python.library.ipaddress#ipaddress.IPv6Interface.with_netmask |
with_prefixlen | python.library.ipaddress#ipaddress.IPv6Interface.with_prefixlen |
class ipaddress.IPv6Network(address, strict=True)
Construct an IPv6 network definition. address can be one of the following:
A string consisting of an IP address and an optional prefix length, separated by a slash (/). The IP address is the network address, and the prefix length must be a single number, the prefix. If no prefix length is provided, it’s considered to be /128. Note that currently expanded netmasks are not supported. That means 2001:db00::0/24 is a valid argument while 2001:db00::0/ffff:ff00:: not. An integer that fits into 128 bits. This is equivalent to a single-address network, with the network address being address and the mask being /128. An integer packed into a bytes object of length 16, big-endian. The interpretation is similar to an integer address. A two-tuple of an address description and a netmask, where the address description is either a string, a 128-bits integer, a 16-bytes packed integer, or an existing IPv6Address object; and the netmask is an integer representing the prefix length. An AddressValueError is raised if address is not a valid IPv6 address. A NetmaskValueError is raised if the mask is not valid for an IPv6 address. If strict is True and host bits are set in the supplied address, then ValueError is raised. Otherwise, the host bits are masked out to determine the appropriate network address. Changed in version 3.5: Added the two-tuple form for the address constructor parameter.
version
max_prefixlen
is_multicast
is_private
is_unspecified
is_reserved
is_loopback
is_link_local
network_address
broadcast_address
hostmask
netmask
with_prefixlen
compressed
exploded
with_netmask
with_hostmask
num_addresses
prefixlen
hosts()
Returns an iterator over the usable hosts in the network. The usable hosts are all the IP addresses that belong to the network, except the Subnet-Router anycast address. For networks with a mask length of 127, the Subnet-Router anycast address is also included in the result. Networks with a mask of 128 will return a list containing the single host address.
overlaps(other)
address_exclude(network)
subnets(prefixlen_diff=1, new_prefix=None)
supernet(prefixlen_diff=1, new_prefix=None)
subnet_of(other)
supernet_of(other)
compare_networks(other)
Refer to the corresponding attribute documentation in IPv4Network.
is_site_local
These attribute is true for the network as a whole if it is true for both the network address and the broadcast address. | python.library.ipaddress#ipaddress.IPv6Network |
address_exclude(network) | python.library.ipaddress#ipaddress.IPv6Network.address_exclude |
broadcast_address | python.library.ipaddress#ipaddress.IPv6Network.broadcast_address |
compare_networks(other)
Refer to the corresponding attribute documentation in IPv4Network. | python.library.ipaddress#ipaddress.IPv6Network.compare_networks |
compressed | python.library.ipaddress#ipaddress.IPv6Network.compressed |
exploded | python.library.ipaddress#ipaddress.IPv6Network.exploded |
hostmask | python.library.ipaddress#ipaddress.IPv6Network.hostmask |
hosts()
Returns an iterator over the usable hosts in the network. The usable hosts are all the IP addresses that belong to the network, except the Subnet-Router anycast address. For networks with a mask length of 127, the Subnet-Router anycast address is also included in the result. Networks with a mask of 128 will return a list containing the single host address. | python.library.ipaddress#ipaddress.IPv6Network.hosts |
is_link_local | python.library.ipaddress#ipaddress.IPv6Network.is_link_local |
is_loopback | python.library.ipaddress#ipaddress.IPv6Network.is_loopback |
is_multicast | python.library.ipaddress#ipaddress.IPv6Network.is_multicast |
is_private | python.library.ipaddress#ipaddress.IPv6Network.is_private |
is_reserved | python.library.ipaddress#ipaddress.IPv6Network.is_reserved |
is_site_local
These attribute is true for the network as a whole if it is true for both the network address and the broadcast address. | python.library.ipaddress#ipaddress.IPv6Network.is_site_local |
is_unspecified | python.library.ipaddress#ipaddress.IPv6Network.is_unspecified |
max_prefixlen | python.library.ipaddress#ipaddress.IPv6Network.max_prefixlen |
netmask | python.library.ipaddress#ipaddress.IPv6Network.netmask |
network_address | python.library.ipaddress#ipaddress.IPv6Network.network_address |
num_addresses | python.library.ipaddress#ipaddress.IPv6Network.num_addresses |
overlaps(other) | python.library.ipaddress#ipaddress.IPv6Network.overlaps |
prefixlen | python.library.ipaddress#ipaddress.IPv6Network.prefixlen |
subnets(prefixlen_diff=1, new_prefix=None) | python.library.ipaddress#ipaddress.IPv6Network.subnets |
subnet_of(other) | python.library.ipaddress#ipaddress.IPv6Network.subnet_of |
supernet(prefixlen_diff=1, new_prefix=None) | python.library.ipaddress#ipaddress.IPv6Network.supernet |
supernet_of(other) | python.library.ipaddress#ipaddress.IPv6Network.supernet_of |
version | python.library.ipaddress#ipaddress.IPv6Network.version |
with_hostmask | python.library.ipaddress#ipaddress.IPv6Network.with_hostmask |
with_netmask | python.library.ipaddress#ipaddress.IPv6Network.with_netmask |
with_prefixlen | python.library.ipaddress#ipaddress.IPv6Network.with_prefixlen |
ipaddress.ip_address(address)
Return an IPv4Address or IPv6Address object depending on the IP address passed as argument. Either IPv4 or IPv6 addresses may be supplied; integers less than 2**32 will be considered to be IPv4 by default. A ValueError is raised if address does not represent a valid IPv4 or IPv6 address. >>> ipaddress.ip_address('192.168.0.1')
IPv4Address('192.168.0.1')
>>> ipaddress.ip_address('2001:db8::')
IPv6Address('2001:db8::') | python.library.ipaddress#ipaddress.ip_address |
ipaddress.ip_interface(address)
Return an IPv4Interface or IPv6Interface object depending on the IP address passed as argument. address is a string or integer representing the IP address. Either IPv4 or IPv6 addresses may be supplied; integers less than 2**32 will be considered to be IPv4 by default. A ValueError is raised if address does not represent a valid IPv4 or IPv6 address. | python.library.ipaddress#ipaddress.ip_interface |
ipaddress.ip_network(address, strict=True)
Return an IPv4Network or IPv6Network object depending on the IP address passed as argument. address is a string or integer representing the IP network. Either IPv4 or IPv6 networks may be supplied; integers less than 2**32 will be considered to be IPv4 by default. strict is passed to IPv4Network or IPv6Network constructor. A ValueError is raised if address does not represent a valid IPv4 or IPv6 address, or if the network has host bits set. >>> ipaddress.ip_network('192.168.0.0/28')
IPv4Network('192.168.0.0/28') | python.library.ipaddress#ipaddress.ip_network |
exception ipaddress.NetmaskValueError(ValueError)
Any value error related to the net mask. | python.library.ipaddress#ipaddress.NetmaskValueError |
ipaddress.summarize_address_range(first, last)
Return an iterator of the summarized network range given the first and last IP addresses. first is the first IPv4Address or IPv6Address in the range and last is the last IPv4Address or IPv6Address in the range. A TypeError is raised if first or last are not IP addresses or are not of the same version. A ValueError is raised if last is not greater than first or if first address version is not 4 or 6. >>> [ipaddr for ipaddr in ipaddress.summarize_address_range(
... ipaddress.IPv4Address('192.0.2.0'),
... ipaddress.IPv4Address('192.0.2.130'))]
[IPv4Network('192.0.2.0/25'), IPv4Network('192.0.2.128/31'), IPv4Network('192.0.2.130/32')] | python.library.ipaddress#ipaddress.summarize_address_range |
ipaddress.v4_int_to_packed(address)
Represent an address as 4 packed bytes in network (big-endian) order. address is an integer representation of an IPv4 IP address. A ValueError is raised if the integer is negative or too large to be an IPv4 IP address. >>> ipaddress.ip_address(3221225985)
IPv4Address('192.0.2.1')
>>> ipaddress.v4_int_to_packed(3221225985)
b'\xc0\x00\x02\x01' | python.library.ipaddress#ipaddress.v4_int_to_packed |
ipaddress.v6_int_to_packed(address)
Represent an address as 16 packed bytes in network (big-endian) order. address is an integer representation of an IPv6 IP address. A ValueError is raised if the integer is negative or too large to be an IPv6 IP address. | python.library.ipaddress#ipaddress.v6_int_to_packed |
exception IsADirectoryError
Raised when a file operation (such as os.remove()) is requested on a directory. Corresponds to errno EISDIR. | python.library.exceptions#IsADirectoryError |
isinstance(object, classinfo)
Return True if the object argument is an instance of the classinfo argument, or of a (direct, indirect or virtual) subclass thereof. If object is not an object of the given type, the function always returns False. If classinfo is a tuple of type objects (or recursively, other such tuples), return True if object is an instance of any of the types. If classinfo is not a type or tuple of types and such tuples, a TypeError exception is raised. | python.library.functions#isinstance |
issubclass(class, classinfo)
Return True if class is a subclass (direct, indirect or virtual) of classinfo. A class is considered a subclass of itself. classinfo may be a tuple of class objects, in which case every entry in classinfo will be checked. In any other case, a TypeError exception is raised. | python.library.functions#issubclass |
iter(object[, sentinel])
Return an iterator object. The first argument is interpreted very differently depending on the presence of the second argument. Without a second argument, object must be a collection object which supports the iteration protocol (the __iter__() method), or it must support the sequence protocol (the __getitem__() method with integer arguments starting at 0). If it does not support either of those protocols, TypeError is raised. If the second argument, sentinel, is given, then object must be a callable object. The iterator created in this case will call object with no arguments for each call to its __next__() method; if the value returned is equal to sentinel, StopIteration will be raised, otherwise the value will be returned. See also Iterator Types. One useful application of the second form of iter() is to build a block-reader. For example, reading fixed-width blocks from a binary database file until the end of file is reached: from functools import partial
with open('mydata.db', 'rb') as f:
for block in iter(partial(f.read, 64), b''):
process_block(block) | python.library.functions#iter |
iterator.__iter__()
Return the iterator object itself. This is required to allow both containers and iterators to be used with the for and in statements. This method corresponds to the tp_iter slot of the type structure for Python objects in the Python/C API. | python.library.stdtypes#iterator.__iter__ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.