[Python-Dev] PEP 3144 review.

Antoine Pitrou solipsis at pitrou.net
Sun Sep 27 22:15:26 CEST 2009


Peter Moody <peter <at> hda3.com> writes:
> 
> On Sun, Sep 27, 2009 at 12:40 PM, James Y Knight <foom <at> fuhm.net> wrote:
> >
> > On Sep 27, 2009, at 3:18 PM, Peter Moody wrote:
> >
> >> administrators) would use it, but it's doable. what you're claiming is
> >> that my use case is invalid.
> >>
> >> that's what I claim is broken.
> >
> > He's claiming your solution to address your use case is confusing, not that
> > the use case is invalid.
> 
> this isn't actually true.
> 
> Steven D'Aprano wrote:
[...]

That's Steven, your original sentence was about me.

> > 1) if strict=False, mask off the bits described by the netmask when creating
> > an IPNetwork, such that the host bits are always 0.
> 
> I haven't heard anyone suggest auto-masking bits, but otherwise that
> would be strict=True.

I would expect strict=True to raise an error if the lower bits are non-zero, not
to silently erase them. strict=False would be the option that silently erases
lower bits.
(that's why it's named `strict`, after all :-))

> > 2) add a single new function:
> >
> > def parse_net_and_addr(s):
> >  return (IPNetwork(s), IPAddress(s.split('/')[0]))
> 
> I've only heard talk of new classes and new methods, not new
> constructor functions.

Well, "method" in that context meant "class method" since the results aren't
dependent on a particular instance. Of course, both a class method or a
module-level function would be fine.

Regards

Antoine.




More information about the Python-Dev mailing list