On this page
ipaddress.IPv4Interface
Prev: ipaddress.IPv4Address | Up: ipaddress | Next: ipaddress.IPv4Network
Rel: ipaddress.AddressValueError, ipaddress.collapse_addresses, ipaddress.get_mixed_type_key, ipaddress.ip_address
Ref: docs.python.org — ipaddress.IPv4Interface
Tags: #public #python3 #stdlib #ipaddress
Import
import ipaddress
from ipaddress import IPv4Interface
Signature & Overview
ipaddress.IPv4Interface(address)
ipaddress.IPv4Interface class.
Methods & Attributes
IPv4Interface.compressed(...)— Return the shorthand version of the IP address as a string.IPv4Interface.exploded(...)— Return the longhand version of the IP address as a string.IPv4Interface.ip(...)—IPv4Interface.ipmethod/property.IPv4Interface.ipv6_mapped(...)— Return the IPv4-mapped IPv6 address.IPv4Interface.is_global(...)—Trueif the address is defined as globally reachable by iana-ipv4-special-registry_ (for IPv4) or iana-ipv6-special-registry_ (for IPv6) with the following exception:IPv4Interface.is_link_local(...)— Test if the address is reserved for link-local.IPv4Interface.is_loopback(...)— Test if the address is a loopback address.IPv4Interface.is_multicast(...)— Test if the address is reserved for multicast use.IPv4Interface.is_private(...)—Trueif the address is defined as not globally reachable by iana-ipv4-special-registry_ (for IPv4) or iana-ipv6-special-registry_ (for IPv6) with the following exceptions:IPv4Interface.is_reserved(...)— Test if the address is otherwise IETF reserved.IPv4Interface.is_unspecified(...)— Test if the address is unspecified.IPv4Interface.packed(...)— The binary representation of this address.IPv4Interface.reverse_pointer(...)— The name of the reverse DNS pointer for the IP address, e.g.: >>> ipaddress.ip_address("127.0.0.1").reverse_pointer '1.0.0.127.in-addr.arpa'IPv4Interface.with_hostmask(...)—IPv4Interface.with_hostmaskmethod/property.IPv4Interface.with_netmask(...)—IPv4Interface.with_netmaskmethod/property.IPv4Interface.with_prefixlen(...)—IPv4Interface.with_prefixlenmethod/property.
Usage
import ipaddress
iface = ipaddress.IPv4Interface("192.168.1.10/24")
assert str(iface.ip) == "192.168.1.10"
assert str(iface.network) == "192.168.1.0/24"
Gotchas
- Combines a host address AND its subnet mask: Unlike
IPv4Network("192.168.1.10/24"), it keeps the.10host bits.
REPL Inspect
from ipaddress import IPv4Interface
help(IPv4Interface)
Linked from
Related notes
- tuts/python3/stdlib_module/ipaddress/IPv4Address Linked here; links to this page; shared tags: #ipaddress, #stdlib
- tuts/python3/stdlib_module/ipaddress/IPv4Network Linked here; links to this page; shared tags: #ipaddress, #stdlib
- tuts/python3/stdlib_module/ipaddress Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/ipaddress/AddressValueError Linked here; shared tags: #ipaddress, #stdlib
- tuts/python3/stdlib_module/ipaddress/collapse_addresses Linked here; shared tags: #ipaddress, #stdlib
- tuts/python3/stdlib_module/ipaddress/get_mixed_type_key Linked here; shared tags: #ipaddress, #stdlib
- tuts/python3/stdlib_module/ipaddress/ip_address Linked here; shared tags: #ipaddress, #stdlib
- tuts/python3/stdlib_module/ipaddress/ip_interface shared tags: #ipaddress, #stdlib
- tuts/python3/stdlib_module/ipaddress/ip_network shared tags: #ipaddress, #stdlib
- tuts/python3/stdlib_module/ipaddress/IPv6Address shared tags: #ipaddress, #stdlib