New submission from Lord Anton Hvornum: https://docs.python.org/3/library/ipaddress.html#ipaddress.IPv4Network.hosts
I couldn't find anywhere in the documentation mentioning the fact that doing the following would return nothing: >>> import ipaddress >>> net = ipaddress.ip_network('127.0.0.1/32') >>> list(net.hosts()) [] For all intense and purposes, that network still contains hosts. That being one single lonely host of '127.0.0.1'. It's illogical to not return any hosts if there actually are one or more in there. Now the programmer has to do a one-off-check to see if this particular defined network (of a huge list usually) happens to end with /32, then it needs to treat the item not as a defined network (even tho it is with a netmask), but rather strip the netmask and treat it as a single host entity.. It makes no sense if you're iterating over a huge list of network infrastructure. ---------- components: Library (Lib) messages: 303063 nosy: Lord Anton Hvornum priority: normal severity: normal status: open title: ipaddress.hosts() doesn't return anything on a /32 "network" type: behavior versions: Python 3.6, Python 3.7, Python 3.8 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue31597> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com