IPy

1.01 · maintenance · verified Mon Apr 13

IPy is a Python library providing classes and tools for handling IPv4 and IPv6 addresses and networks. It aims to offer a comfortable parsing and manipulation interface for various IP address notations, similar to Perl's Net::IP module. The current version is 1.01, and it appears to be in maintenance mode with no recent updates.

Warnings

Install

Imports

Quickstart

Demonstrates creating IP and IPSet objects, iterating through a network, checking IP types, and performing set operations.

from IPy import IP, IPSet

# Working with individual IP addresses and networks
ip_network = IP('192.168.1.0/24')
print(f"Network: {ip_network}")
print(f"Version: {ip_network.version()}")
for ip_addr in ip_network:
    print(f"  Host: {ip_addr}")

ip_host = IP('::1')
print(f"IPv6 Host: {ip_host}")
print(f"Is loopback: {ip_host.iptype() == 'LOOPBACK'}")

# Working with IPSet for multiple ranges
s = IPSet([IP('10.0.0.0/22')])
s.add(IP('192.168.1.0/29'))
print(f"IPSet: {s}")
print(f"Is disjoint from 172.16.0.0/12: {s.isdisjoint(IPSet([IP('172.16.0.0/12')]))}")

view raw JSON →