On this page
ipaddress.ip_interface
Prev: ipaddress.ip_address | Up: ipaddress | Next: ipaddress.ip_network
Rel: ipaddress.AddressValueError, ipaddress.collapse_addresses, ipaddress.get_mixed_type_key, ipaddress.ip_address
Ref: docs.python.org — ipaddress.ip_interface
Tags: #public #python3 #stdlib #ipaddress
Import
import ipaddress
from ipaddress import ip_interface
Signature & Overview
ipaddress.ip_interface(address)
Take an IP string/int and return an object of the correct type.
Usage
import ipaddress
iface = ipaddress.ip_interface("10.0.0.5/8")
assert iface.version == 4 and str(iface.network) == "10.0.0.0/8"
Gotchas
- Auto-detects IPv4 vs. IPv6 interface strings.
REPL Inspect
from ipaddress import ip_interface
help(ip_interface)
Linked from
Related notes
- tuts/python3/stdlib_module/ipaddress/AddressValueError Linked here; links to this page; shared tags: #ipaddress, #stdlib
- tuts/python3/stdlib_module/ipaddress/collapse_addresses Linked here; links to this page; shared tags: #ipaddress, #stdlib
- tuts/python3/stdlib_module/ipaddress/get_mixed_type_key Linked here; links to this page; shared tags: #ipaddress, #stdlib
- tuts/python3/stdlib_module/ipaddress/ip_address Linked here; links to this page; shared tags: #ipaddress, #stdlib
- tuts/python3/stdlib_module/ipaddress/ip_network 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/IPv4Address shared tags: #ipaddress, #stdlib
- tuts/python3/stdlib_module/ipaddress/IPv4Interface shared tags: #ipaddress, #stdlib
- tuts/python3/stdlib_module/ipaddress/IPv4Network shared tags: #ipaddress, #stdlib
- tuts/python3/stdlib_module/ipaddress/IPv6Address shared tags: #ipaddress, #stdlib