[Python-Dev] PEP 3144 review.
Terry Reedy
tjreedy at udel.edu
Wed Sep 30 18:38:44 CEST 2009
Mark Dickinson wrote:
> On Wed, Sep 30, 2009 at 1:44 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> 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'
>
> Is this just a problem of education, teaching the users not to abuse
> IPv4Network this way? Or is this just an unlikely use of IPv4Network?
> Or have I misunderstood the proposal altogether?
This gets at why I suggested the docs be organized as I suggested, with
'Network is range of addresses defined by address within range ...'
and 'Definition address is retained' *immediately* followed by
'Definition address is mostly ignored, including for comparisons'. The
latter caveat should mention the implication for hash() and set/dict
membership. The point is to emphasize from the beginning that a network
is a network (with an address, that many will ignore), rather than an
address (with a network).
Terry Jan Reedy
More information about the Python-Dev
mailing list