ipaddress.ip_interface()
ipaddress.ip_interface() is a Python function in the IP Address Module category. Creates an IPv4Interface or IPv6Interface (host with network). The syntax is ipaddress.ip_interface(address). Returns: IPv4Interface or IPv6Interface. A typical example: iface = ipaddress.ip_interface("192.168.1.1/24")
iface.ip # IPv4Address("192.168.1.1")
iface.network # IPv4Network("192.168.1.0/24"). A close sibling is ipaddress.ip_address(), which creates an IPv4Address or IPv6Address object from a string. A close sibling is ipaddress.ip_network(), which creates an IPv4Network or IPv6Network object from an IP network string. A close sibling is IPv4Address.is_private, which returns True if the address is in a private IP range. A close sibling is IPv4Address.is_loopback, which returns True if the address is a loopback address (127.0.0.0/8). More about this category: IP address handling — IPv4Address, IPv6Address, IPv4Network, IPv6Network. Related IP Address Module entries: ipaddress.ip_address(), ipaddress.ip_network(), IPv4Address.is_private, IPv4Address.is_loopback, IPv4Address.is_multicast, IPv4Address.is_global. This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details.