ipaddress.IPv4Network.compare_networks()

compare_networks(other)

Compare this network to other. In this comparison only the network addresses are considered; host bits aren’t. Returns either -1, 0 or 1.

1
2
3
4
5
6
>>> ip_network('192.0.2.1/32').compare_networks(ip_network('192.0.2.2/32'))
-1
>>> ip_network('192.0.2.1/32').compare_networks(ip_network('192.0.2.0/32'))
1
>>> ip_network('192.0.2.1/32').compare_networks(ip_network('192.0.2.1/32'))
0
doc_python
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.