On Mon, Sep 14, 2009 at 7:11 PM, Andrew McNamara
<andr...@object-craft.com.au> wrote:
>>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:

huh, this appears to be a bug. filing an issue and I'll have this
fixed before anything is submitted
(http://code.google.com/p/ipaddr-py/issues/detail?id=35)

>    >>> ipaddr.IPv4Network('10/8')
>    IPv4Network('0.0.0.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('192.168.1.1/16')
>    IPv4Network('192.168.1.1/16')
>
> This is close:
>
>    >>> ipaddr.IPv4Network('192.168.1.1/16').network
>    IPv4Address('192.168.0.0')
>
> What I want is a method that returns:
>
>    IPv4Network('192.168.0.0/16')

I can see about adding this. you can currently do:

>>> a = ipaddr.IPv4Network('192.168.1.1/16')
>>> '%s/%s' % (a.network, a.prefixlen)
192.168.0.0/16

(I do something very similar to this in address_exclude)

> 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.

no need to apologize, all comments welcome.

> 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.

yeah, I didn't exactly want the PEP to be the pydoc of ipaddr, but I
did want to explain the features and show how I thought they were
important to whatever might be accepted by python. I can certainly go
into much more detail in the PEP if that's deemed important.

Cheers,
/peter

> --
> Andrew McNamara, Senior Developer, Object Craft
> http://www.object-craft.com.au/
>
_______________________________________________
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

Reply via email to