[Python-Dev] PEP 3144 review.
R. David Murray
rdmurray at bitdance.com
Tue Sep 15 20:33:50 CEST 2009
On Tue, 15 Sep 2009 at 14:16, Scott Dial wrote:
> In other words, I don't see why obtaining a host address would *not*
> retain the hostmask from the network it was obtained from. I am not
> disagreeing with it being an individual address. I am disagreeing that
> IPNetwork itself already does represent individual addresses (hence my
> aliasing it with IPAddressWithNetwork). And wrt, the logical return
> would be another IPAddressWithNetwork retaining the same mask.
In other other words, maybe we have three data types:
Where myAddressWithMask.network would return an IPv4Network object,
and an IPv4Network object would always have the zero of the network
as its representation:
x = IPv4AddressWithMask('192.168.1.1/24')
x.network == IPv4Network('192.168.1.0/24')
x.network == x
In this scheme, IPv4Network('192.168.1.1/24') would raise a ValueError.
Although you could probably have what I called IPv4AddressWithMask be
called IPv4Address, and have what is now IPv4Address just have
netmask and network attributes of None.
If this were done, I would expect IPv4Network.network to be either
an attribute error or return self.
More information about the Python-Dev