Open
Description
Feature or enhancement
Proposal:
Intuitively, I thought this would work, but it fails with a TypeError when comparing a slice with an int.
import ipaddress
net = ipaddress.IPv4Network("10.5.5.0/24")
for ip_addr in net[:35]:
print(ip_addr)Currently, _BaseNetwork doesn't support slicing, because the class doesn't implement the __len__ method, for good reason: it could cause a confusion between the number of addresses in the network, or the bitsize for the address.
Because of this, I believe we should implement support for slicing directly into the getter, and potentially extending the support for this into the hosts() function of the same class.
I've created a working implementation for this.
Has this already been discussed elsewhere?
This is a minor feature, which does not need previous discussion elsewhere
Links to previous discussion of this feature:
No response

