[Python-Dev] PEP 3144 review.

rascal jonrascal at gmail.com
Wed Sep 16 04:49:38 CEST 2009

I'd like to see more clear direction for this. Is it a string manipulation
library, or an IP address library?

There are ONLY TWO types of IP representations:
1. Network = 32 bit number AND 32 bit mask. That is the binary AND. The mask
needs to be preserved, but not the network portion. Any library should
return the ANDed result. Whether the number is or, the result after 'and' is the same. Add a strict=false in
case people need it for validation, better yet, add a validation helper
function, but always return the proper form.

2. A host address is an IP address with no network info.  No mask
information, ever.

What about Broadcast / Network IDs?
The "Network-ID or Network Number" and "Broadcast" are meaningless without
1. A network number by itself it's just another address. Its use depends on
context. When routing, it needs a mask.

> route
When writing firewall ACLs, it is a host.

> access-list aclname permit ip any
Since both are valid, preference shouldn't be given. Instead add a helper
for firstip.

2. Same story with broadcast. Use depends on context. Add the lastip helper.

What does iterating over a network mean?
Iterating over the set of addresses in a network must return host addresses.
If it returns a network, then the address should be ANDed, but that would
return the same number for every iteration. Only returning hosts makes

We need to set a solid line between IP String manipulation and IP
If you want an IP with a mask that isn't a network, then you're not doing IP
address manipulation, you're doing string manipulation. There are many use
cases for it, but it's a separate consideration to pure IP manipulation.

If string manipulation is desirable, then add another standard library
called ipstring (or a separate class if you want it all jumbled in the same
import).  This way real network computing can be done without weird quirks
of representation.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20090915/a2449da2/attachment.htm>

More information about the Python-Dev mailing list