Python Glossary Русский

Python 3.3+ipaddressterm

ipaddress.IPv6Interface

interfaces

An IPv6 address together with its network, for example '2001:db8::5/64' from an interface setting.

Syntax

ipaddress.IPv6Interface(address)

Like IPv4Interface, it is a subclass of the address (IPv6Address), not of the network: it has no in or hosts(), so go through .network for those. Equality and hashing include the prefix, so 2001:db8::5/64 and 2001:db8::5/48 are two distinct set members. The bare address is .ip.

Examples

import ipaddress
iface = ipaddress.IPv6Interface('2001:db8::5/64')
print(iface.ip, iface.network)  # → 2001:db8::5 2001:db8::/64
print(len({iface, ipaddress.IPv6Interface('2001:db8::5/48')}))  # → 2

See also

Common errors

Open in the full glossarydocs.python.orgReport an inaccuracy