[Python-Dev] PEP 3144 review. (original) (raw)
Steven D'Aprano steve at pearwood.info
Thu Sep 17 19:44:31 CEST 2009
- Previous message: [Python-Dev] PEP 3144 review.
- Next message: [Python-Dev] PEP 3144 review.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, 17 Sep 2009 10:40:47 pm Nick Coghlan wrote:
Antoine Pitrou wrote: > Peter Moody <peter hda3.com> writes: >> the address with all of the hosts bits masked to zero is most >> commonly referred to as the network address. same as the address >> with all of the host bits set to one is called the broadcast >> address. calling it something like baseaddress or minaddress >> will cause quite a bit more confusion. > > Quite a bit less IMO. I'm not a network specialist, but the > "network address"
Nah, network address is perfectly explicit - it's what you get when you bitwise and any host within that network with the netmask.
[soapbox] I really wish people would stop misusing the word "explicit" to mean (apparently) "I know how this is commonly defined".
To a non-specialist, "the network address" is ambiguous. There are many addresses in a network, and none of them are the entire network. It's like saying, given a list [2, 4, 8, 12], what's "the list item"?
If network specialists have a convention of calling hostadd&netmask "the network address", that's fine. It's jargon which seems illogical to me, but if it's useful and in common use, specialists will expect us to support it. But it's not explicit, it's a definition.
Where it becomes confusing is that we have a property called "network" that returns an IPAddress object rather than an IPNetwork object.
People that are network specialists would grasp that fairly easily, but we try to design standard library APIs so that they're novice friendly as well. And the above situation isn't novice friendly.
+1000 on this!
To be honest, given the indexing behaviour, I'm -1 on the idea of giving the network address or broadcast address attribute names *at all*. Consider:
networkaddress = mynet[0] broadcastaddress = mynet[-1] The only way the network address could match the number of characters in the indexing method is if you just called it the network id (i.e. mynet.id). For the broadcast address, there is no name that even comes close to matching the indexing approach for brevity.
Is brevity so much more important than clarity and discoverability?
-- Steven D'Aprano
- Previous message: [Python-Dev] PEP 3144 review.
- Next message: [Python-Dev] PEP 3144 review.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]