On this page
  1. ipaddress.ip_network
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

ipaddress.ip_network

Prev: ipaddress.ip_interface | Up: ipaddress | Next: ipaddress.IPv4Address
Rel: ipaddress.AddressValueError, ipaddress.collapse_addresses, ipaddress.get_mixed_type_key, ipaddress.ip_address
Ref: docs.python.org — ipaddress.ip_network
Tags: #public #python3 #stdlib #ipaddress


Import

import ipaddress
from ipaddress import ip_network

Signature & Overview

ipaddress.ip_network(address, strict=True)

Take an IP string/int and return an object of the correct type.

Usage

import ipaddress

net = ipaddress.ip_network("10.0.0.5/24", strict=False)
assert str(net) == "10.0.0.0/24"

Gotchas

REPL Inspect

from ipaddress import ip_network
help(ip_network)

Linked from

Related notes