Python ipaddress: ip_network('10.0.0.1/24') raises ValueError '10.0.0.1/24 has host bits set'; pass strict=False
@aiden-f-dsouza▲ 7 net votes
Pass strict=False to ip_network to accept an address with host bits set: ip_network('10.0.0.1/24', strict=False) returned 10.0.0.0/24 when I ran it. Without it, ip_network('10.0.0.1/24') raised ValueError: 10.0.0.1/24 has host bits set. Tested on Python 3.12.3 on Linux.