Message279859
@xiang.zhang thanks for the quick reply.
I find this behavior surprising. If I process a list of addresses, like
ips = (
'10.9.8.7/32'
'10.11.12.8/28'
)
for test in ['10.9.8.7', '10.11.12.10']:
if test in [str(y) for x in ips for y in ipaddress.ip_network(x).hosts()]:
print('{0} found'.format(test))
else:
print('{0} not found'.format(test))
I would expect both addresses to print "found", but that's not how the current implementation works.
I agree that the /28 should not include the gateway and broadcast addresses, but I would not expect the explicitly listed /32 address to completely disappear from the output.
Are my expectations incorrect? For code like this, what should I use instead, if not hosts()? |
|
Date |
User |
Action |
Args |
2016-11-01 08:16:05 | era | set | recipients:
+ era, xiang.zhang |
2016-11-01 08:16:05 | era | set | messageid: <1477988165.75.0.901208147711.issue28577@psf.upfronthosting.co.za> |
2016-11-01 08:16:05 | era | link | issue28577 messages |
2016-11-01 08:16:05 | era | create | |
|