[Python-Dev] PEP 3144 review. (original) (raw)

Steven D'Aprano steve at pearwood.info
Sun Sep 27 19:30:29 CEST 2009


On Mon, 28 Sep 2009 02:47:27 am Peter Moody wrote:

> There was a proposal to have a separate parseaddressandmask > method which would return a (Address, Network) tuple, I still don't > know why you don't seem to consider it seriously, rather than > trying to make the Network class a kind of all-in-one type > conflating different concepts.

The reason (aside from the name) that I'm not going to include this in ipaddr is that it would require the user to deal with two objects when one would suffice. It's similar to getting two return values from float(). integer, fraction = float('1.25') crazy, right?

Not if you want a separate integer and fraction object. There are plenty of use-cases for such things, and the math module includes a function, modf(), that does precisely that..

Finally, to Stephen's point about seeing the other side of the argument, I wrote this offlist a week ago:

I understand what you're saying, I understand that 192.168.1.1/24 isn't a network,

But you still want to treat it as one.

Could you explain what benefit there is for allowing the user to create network objects that don't represent networks? Is there a use-case where these networks-that-aren't-networks are something other than a typo? Under what circumstances would I want to specify a network as 192.168.1.1/24 instead of 192.168.1.0/24?

-- Steven D'Aprano



More information about the Python-Dev mailing list