On this page
ipaddress.summarize_address_range
Prev: ipaddress.NetmaskValueError | Up: ipaddress | Next: ipaddress.v4_int_to_packed
Rel: ipaddress.AddressValueError, ipaddress.collapse_addresses, ipaddress.get_mixed_type_key, ipaddress.ip_address
Ref: docs.python.org — ipaddress.summarize_address_range
Tags: #public #python3 #stdlib #ipaddress
Import
import ipaddress
from ipaddress import summarize_address_range
Signature & Overview
ipaddress.summarize_address_range(first, last)
Summarize a network range given the first and last IP addresses.
Usage
import ipaddress
nets = list(ipaddress.summarize_address_range(
ipaddress.IPv4Address("192.168.0.0"),
ipaddress.IPv4Address("192.168.0.255"),
))
assert nets == [ipaddress.IPv4Network("192.168.0.0/24")]
Gotchas
- Converts an inclusive
[first, last]IP range into minimal CIDR blocks.
REPL Inspect
from ipaddress import summarize_address_range
help(summarize_address_range)
Linked from
Related notes
- tuts/python3/stdlib_module/ipaddress/NetmaskValueError Linked here; links to this page; shared tags: #ipaddress, #stdlib
- tuts/python3/stdlib_module/ipaddress/v4_int_to_packed 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/IPv4Address shared tags: #ipaddress, #stdlib