[Python-Dev] PEP 3144 review.

Andrew McNamara andrewm at object-craft.com.au
Fri Sep 18 02:57:41 CEST 2009


>> Conceptually, you sometimes need a bare address, and other times,
>> you need an address with an associated network (host interface
>> configs, router configs, etc). By AddressWithMask, I really mean 
>> AddressWithEnoughInformationToDeriveNetworkWhenNeeded. Conveniently,
>> IPv4 and IPv6 addressing allows us to derive the network from the
>> host address combined with the netmask - in other words, we don't
>> have to attach a real Network object to Address objects until the
>> user tries to access it, and then we derive it from the address and
>> mask.
>
>To clarify: when you say "derive the network" are you talking about the 
>network (which is a container) or the network address = host_address & 
>netmask (which is not a container)? I think you're referring to the 
>later.

I mean a Network object which is a container (which, by definition,
has a network address + mask).

>If there's need for address+netmask, does it need to be a separate 
>class? Perhaps Address objects could simply have a netmask property, 
>defaulting to None. If you need an "address with mask" object, you 
>create an Address and set the mask:
>
>addr = Address(...)
>addr.netmask = "255.255.255.0"

Greg Ewing suggested this yesterday - I'm neutral on whether it's done this
way or as a separate class. The implementation may be somewhat cleaner if
it's a separate class, however.

>> If you have a .network attribute on an address object, checking if an
>> address is in the same network as another address becomes:
>>
>>     addr_a in addr_b.network
>>
>> As the module stands, you write that as:
>>
>>     addr_a in addr_b
>>
>> I don't think the intent is as clear with the later.
>
>I would find the later completely unclear and disturbing -- how can one 
>address contain another address?

Yes - that's how it works now, and I can only see it resulting in
confusion and bugs for no advantage.

-- 
Andrew McNamara, Senior Developer, Object Craft
http://www.object-craft.com.au/


More information about the Python-Dev mailing list