On Wed, Sep 30, 2009 at 10:52 AM, Paul Moore <p.f.mo...@gmail.com> wrote: > 2009/9/30 Mark Dickinson <dicki...@gmail.com>: >> Please could someone who understands the uses of IPNetwork better than >> I do explain why the following wouldn't be a significant problem, if __eq__ >> and __hash__ were modified to disregard the .ip attribute as suggested: >> >>>>> linus = IPv4Network('172.16.200.1/24') >>>>> snoopy = IPv4Network('172.16.200.3/24') >>>>> fqdn = {linus: 'linus.peanuts.net', snoopy: 'snoopy.peanuts.net'} >>>>> fqdn[linus] # expecting 'linus.peanuts.net' >> 'snoopy.peanuts.net' > > I certainly don't understand IPv4Network better than you :-) But that > just looks wrong to me - linus and snoopy are hosts not networks, so > making them IPv4Network classes seems wrong. I'd instinctively make > them IPv4Address objects (which, I believe, would work).
Okay, so maybe this is an abuse of IPv4Network. But I'd (mis?)understood that the retention of the .ip attribute was precisely a convenience to allow this sort of use. If not, then what's it for? I've read the PEP and almost all of this thread, but I can't help feeling I'm still missing something. If someone could point out the obvious to me I'd be grateful. I don't have any opinion on whether the ip attribute should be retained or not; but retaining it *and* ignoring it in comparisons just seems a bit odd. Mark _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com