[Python-Dev] PEP 3144 review.

Andrew McNamara andrewm at object-craft.com.au
Tue Sep 15 04:11:30 CEST 2009

>I believe PEP 3144 is ready for your review.  When you get a chance,
>can you take a look/make a pronouncement?

In my experience it is common to leave out the masked octets when
referring to an IPv4 network (the octets are assumed to be zero), so I
don't agree with this behaviour from the reference implementation:

    >>> ipaddr.IPv4Network('10/8')
    >>> ipaddr.IPv4Network('192.168/16')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/usr/src/py/ipaddr/ipaddr.py", line 1246, in __init__
        raise IPv4IpValidationError(addr[0])
    ipaddr.IPv4IpValidationError: '192.168' is not a valid IPv4 address

I also couldn't see an easy way to get from a network address to the
containing network. For example:

    >>> ipaddr.IPv4Network('')

This is close:

    >>> ipaddr.IPv4Network('').network

What I want is a method that returns:


I appreciate these requests are somewhat contradictory (one calls
for masked octets to be insignificant, the other calls for them to be
significant), but they are both valid use cases in my experience.

Apologies if these have already been covered in prior discussion -
I've tried to keep up, but I haven't been able to give it the attention
it deserves.

I also note that many methods in the reference implementation are not
discussed in the PEP. While I don't consider this a problem for the PEP,
anyone reviewing the module for inclusion in the standard lib needs to 
consider them.

Andrew McNamara, Senior Developer, Object Craft

More information about the Python-Dev mailing list