[Python-Dev] PEP 3144 review. (original) (raw)
Nick Coghlan ncoghlan at gmail.com
Wed Sep 30 13:06:09 CEST 2009
- Previous message: [Python-Dev] PEP 3144 review.
- Next message: [Python-Dev] PEP 3144 review.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Mark Dickinson wrote:
On Wed, Sep 30, 2009 at 10:52 AM, Paul Moore <p.f.moore at gmail.com> wrote:
2009/9/30 Mark Dickinson <dickinsm at 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.
You're not missing anything that I'm aware of - unlike the use case for accepting a denormalised network definition in the IPNetwork constructor (which has been made quite clear in the list discussion, even if it is still a bit vague in the PEP), the use case for retaining the host information on the network object hasn't been well articulated at all.
The closest anyone has come to describing a use case is an indirect comment via Guido that leaving out the attribute would involve real code having to find somewhere else to stash the original address details (e.g. by passing around an IPAddres/IPNetwork tuple rather than just an IPNetwork object).
However, while I'd still be a little happier if the .ip attribute went away all together and another means was found to conveniently associate an IPAddress and an IPNetwork, keeping it doesn't bother me anywhere near as much as having network equivalence defined in terms of something other than the network ID and the netmask.
Cheers, Nick.
-- Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
- Previous message: [Python-Dev] PEP 3144 review.
- Next message: [Python-Dev] PEP 3144 review.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]