Peter Moody wrote:
On Tue, Sep 15, 2009 at 10:16 AM, Scott Dial <scott+python-dev@scottdial.com> wrote:
In the end, I found the names IPNetwork/IPAddress and their instantiations confusing. ISTM that IPNetwork is overloaded and plays two roles of being an IPNetwork and being an IPAddressWithNetwork. And finally, it's unclear to me why iterating over a IPNetwork would not produce a sequence of IPNetwork(/IPAddressWithNetwork) objects.
What you're describing, at least for the networks, is basically what ipaddr was. It seemed, after much heated discussion, that the community felt that
ipaddr.IPv4Network('1.1.1.0/24')[0]
was actually an individual address. ie, each of the addresses in 1.1.1.0/24 are individual addresses, rather than networks with /32 prefix lengths.
For clarity, I am going to call the current design "A": ipaddr.IPv4Network('1.1.1.0/24')[0] == ipaddr.IPv4Address('1.1.1.0') And what itt sounds like what you are describing as the old behavior is this (design "B"): ipaddr.IPv4Network('1.1.1.0/24')[0] == ipaddr.IPv4Network('1.1.1.0/32') Which is different than what I was trying to describe. I expected (design "C"): ipaddr.IPv4Network('1.1.1.0/24')[0] == ipaddr.IPv4Network('1.1.1.0/24') My summarization of these designs would be that "B" is wrong. And that "A" is better than "B", certainly. At least "A" is not saying something untrue. However, "C" would be truthful and retains a superset of information that "A" provides (the "ip" attribute of IPNetwork). In other words, I don't see why obtaining a host address would *not* retain the hostmask from the network it was obtained from. I am not disagreeing with it being an individual address. I am disagreeing that IPNetwork itself already does represent individual addresses (hence my aliasing it with IPAddressWithNetwork). And wrt, the logical return would be another IPAddressWithNetwork retaining the same mask. -- Scott Dial scott@scottdial.com scodial@cs.indiana.edu