I was quite surprised — only a few days ago in fact — to discover the standard Python library has no support for Olson (as in tzdata) timezones. Time arithmetic is impossible without them.
The ipaddress library also has no support for calculating subnets. It is quite hard to go from 2a00:aaaa:bbbb::/48 to 2a00:aaaa:bbbb:cccc::/64. It would be less weird if the essence of the documentation didn’t make it sound like the library was otherwise very thorough in the coverage of its implementation.
Can anyone write a PEP? Maybe I should get off my behind and actually submit a patch for proper IP calculations? Or maybe I missed it in the documentation (which, aside, I wish wasn’t written with such GNU-info style formality.)
Unless I misunderstand what you're looking for, I think that functionality is in there.
original_net_48 = ip_network("2a00:aaaa:bbbb::/48")
desired_subnet = ip_network('2a00:aaaa:bbbb:cccc::/64')
subnets_64 = original_net_48.subnets(16)
print(f"{desired_subnet} is one of the computed subnets: {desired_subnet in subnets_64}")
#=> 2a00:aaaa:bbbb:cccc::/64 is one of the computed subnets: True
Oh, yeah, you're right. That's a shame — that function does exactly what you want, but it has to do it for every possible subnet up to the one you want, and the logic isn't included as a separate function.
The ipaddress library also has no support for calculating subnets. It is quite hard to go from 2a00:aaaa:bbbb::/48 to 2a00:aaaa:bbbb:cccc::/64. It would be less weird if the essence of the documentation didn’t make it sound like the library was otherwise very thorough in the coverage of its implementation.
Can anyone write a PEP? Maybe I should get off my behind and actually submit a patch for proper IP calculations? Or maybe I missed it in the documentation (which, aside, I wish wasn’t written with such GNU-info style formality.)