[Python-Dev] PEP 3144 review.

Antoine Pitrou solipsis at pitrou.net
Wed Sep 16 02:20:41 CEST 2009

Peter Moody <peter <at> hda3.com> writes:
> >>>> However, I do not think
> >>>> that the proposed API should accept, eg, IPv4Network('')
> >>>> as valid.  That's just too confusing and error prone.
> >>>
> >>> Indeed, it should throw some kind of ValueError instead.
> >>
> >> Peter, what do you think?
> I disagree. It seems overly pedantic to throw a valueerror on this.
> IPy does (used to do?) this and it's one of the primary reasons I
> wrote ipaddr.

Python is not PHP and does not try to be overly "smart" or tolerant when faced
with bizarrely-formatted input.

I don't see any valid reason for entering a network as "" rather
than the canonical "". The former might indicate a typing error or
a mental slip, so let's be helpful and signal it to the user.

> for addr in ipaddr.IPv4Network('').iterwithnetmask():
>   #,,

I don't have any strong feelings about it, although I don't really think it is
needed, and a plethoric API is not a good thing (neither clarity-wise nor

> this can be done much more cleanly/easily than adding two new
> (redundant in my eyes) classes and much less pedantically than raising
> exceptions w/ IPv?Network() constructor received something other than
> base network address.

I don't think anybody suggested adding two classes. As for the "pedantry" of
thoroughly validating inputs, see above.



More information about the Python-Dev mailing list