[Python-Dev] PEP 3144: IP Address Manipulation Library for the Python Standard Library

R. David Murray rdmurray at bitdance.com
Wed Aug 19 18:21:40 CEST 2009

On Wed, 19 Aug 2009 at 08:19, Peter Moody wrote:
> On Wed, Aug 19, 2009 at 6:47 AM, Tino Wildenhain<tino at wildenhain.de> wrote:
>>> Le Tue, 18 Aug 2009 13:00:06 -0700, Peter Moody a écrit :
>>>>> o.broadcast
>>    IPv4Address('')
>> this is often used but not the only valid broadcast address,
>> in fact, any address between network address and max(address with given
>> netmask) can be defined as broadcast. Maybe biggest or greatest
>> would be better name for the attribute. User is then free to interpret
>> it as broadcast if desired.
>> The attribute network returned as address object also does not seem
>> right.
> by convention, the highest address in a given network is called the
> broadcast address while the lowest address is called the network
> address. They're also distinct addresses, as opposed to networks,
> hence .broadcast/.network/etc returning IPvXAddress objects. calling
> them .biggest and .smallest would be confusing.
> am I misinterpreting what you mean?

Possibly.  Tino means exactly what he said:  the broadcast address
does not _have_ to be the last IP, nor does the last IP _have_ to be
a broadcast, though in practice they almost always are (and using the
last IP as a host IP almost never works in practice in a heterogeneous
network).  Check out the 'broadcast' option of the ifconfig command for
confirmation that the broadcast address can be any IP in the network.
Of course, for that to work all hosts on the network have to agree on
what the broadcast is, hence the normal convention that the broadcast
is the last IP in the network.

As for the 'network' attribute, if you call it 'network' IMO it should
be a network data type, which would make it rather redundant.  What you
are actually returning is what I have normally heard called either the
'zero' of the network, or the "network number" or "network identifier";
but never just "network" (a network has to have at least an implicit
netmask to be meaningful, IMO).

Since you are dealing with networks as a list of addresses, perhaps
you should drop the 'network' attribute, make the 'broadcast' attribute
settable with a default equal to self[-1], and let the user refer to
the zero element to get the zero of the network if they want it.


More information about the Python-Dev mailing list