[Python-Dev] PEP 3144 review.

Peter Moody peter at hda3.com
Sun Sep 27 07:54:21 CEST 2009

On Sat, Sep 26, 2009 at 10:38 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> Peter Moody wrote:
>> I again invite interested parties to continue this discussion on
>> ipaddr-py-dev at googlegroups.com.  we're pushing 250 messages on PEP
>> 3144 at this point; well beyond what most folks would call a "long
>> open-ended discussion".
>> anyway:
>>> The current behaviour is confusing to me. For example:
>>>>>> netw1 = ipaddr.IPv4Network('')
>>>>>> netw2 = ipaddr.IPv4Network('')
>>>>>> netw1 == netw2
>>> False
>>>>>> list(netw1) == list(netw2)
>>> True
>> I think you're intentionally confusing yourself here.
>> clearly doesn't equal, so I don't know why you'd expect
>> to equal
> No, this is exactly the "dual purpose" nature of IPNetwork that people
> have been complaining about: & ==
> &, so the two objects describe the exact same network, but
> the network objects don't currently respect their own netmask, instead
> remembering which particular host happened to be used to derive the
> network ID.
> "Arbitrary network host with associated netmask" and "IP Network" are
> different concepts, but the library currently uses a single class
> interface (IPNetwork) for both of them.
> What we're asking for is for the "ip" attribute to be removed from IP
> Network, with the constructor either forgetting the host IP that was
> used to derive the network address, or else only accepting the correct
> network address in the constructor and providing a separate helper
> function or class method to create an IPNetwork object from an arbitrary
> hostname.

what you want is strict=True, just checked in. I've been meaning to
send an update to the PEP explaining why this choice was made. I'm
hoping this will ameliorate your confusion.


> Cheers,
> Nick.
> --
> Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
> ---------------------------------------------------------------

More information about the Python-Dev mailing list