[Python-Dev] PEP 3144 review.
Greg Ewing
greg.ewing at canterbury.ac.nz
Thu Sep 17 01:56:25 CEST 2009
R. David Murray wrote:
> A network is conventionally represented by an IP address in which the
> bits corresponding to the one bits in the netmask are set to zero, plus
> the netmask.
Okay, that's clarified things for me, thanks.
In that case, we shouldn't be talking about a "network address"
at all, but just a "network", and it makes sense to have
1) A class called IPNetwork that contains an IP number
and a mask, with the IP number constrained not to have
any ones where the mask has zeroes, and
2) A class called IPAddress which only contains an
IP number.
It seems that some people would also like to have
3) A class called IPAddressWithMask that contains an
IP number and a mask, with no constraints,
but I'm not enough of an expert to know whether such
a thing would be used often enough to be worth having
a special type for it, as opposed to using an
(IPNetwork, IPAddress) pair, or attaching a 'network'
attribute to an IPAddress, or some other solution
when the need arises.
--
Greg
More information about the Python-Dev
mailing list