[Python-Dev] Issues with Py3.1's new ipaddr

Jake McGuire mcguire at google.com
Tue Jun 2 03:54:21 CEST 2009


On Mon, Jun 1, 2009 at 12:16 PM, "Martin v. Löwis" <martin at v.loewis.de>wrote:

> As for Clay McLure's issue: I feel it's primarily a matter of taste.
> I see nothing morally wrong in using the same class for hosts and
> networks, i.e. representing a host as a network of size 1. I can
> understand why people dislike that, but I don't see why it would stop
> people from doing with the library what they want to do.
>

To the extent that Clay is having issues, it's because ipaddr.py is poorly
documented, has potentially confusing comments, and he became confused.
 Lesser issues are that ipaddr.py doesn't work the way he wants and that ip
addressing is inherently subtle.

Looking at the code in detail shows that ipaddr.IP/IPv4/IPv6 objects always
represent *networks*.  He wants one particular address out of that network,
and that requires using __getitem__ or using IP.ip_ext. Neither is
particularly intuitive.

>>> import ipaddr
>>> ip = ipaddr.IPv4('10.33.11.17')
>>> ip
IPv4('10.33.11.17/32')
>>> ip[0]
'10.33.11.17'
>>> ip.ip_ext
'10.33.11.17'
>>>

This feels much more like poor documentation than wide-ranging conceptual
flaws.

I could put this in the tracker, but I'm not sure if that's appropriate.

-jake
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20090601/48427223/attachment-0001.htm>


More information about the Python-Dev mailing list