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

Stephen J. Turnbull stephen at xemacs.org
Wed Sep 16 07:48:58 CEST 2009


Antoine Pitrou writes:

An IPv4Address with 'network' and 'mask' attributes that could be None would also not complicate the API, IMO, and would handle both of these use cases.

But it would be confusing and conceptually bizarre, because an address (in usually accepted terminology) doesn't have a network and a mask.

It doesn't need a mask attribute because the network knows that.

OTOH, it would be useful for an address to be able to cache the network it is a member of, because the object that represents a particular network should be unique. That means a lookup in a table, and possibly constructing a new IPv4Network object to represent the anwser if false, if you are given a netmask and asked to deduce the network. And addresses do, implicitly, have a network. Otherwise the're useless!<0.5 wink>



More information about the Python-Dev mailing list