[Python-Dev] PEP 3144 review. (original) (raw)
Daniel Stutzbach daniel at stutzbachenterprises.com
Tue Sep 15 20:32:53 CEST 2009
- Previous message: [Python-Dev] PEP 3144 review.
- Next message: [Python-Dev] PEP 3144 review.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tue, Sep 15, 2009 at 12:16 PM, Scott Dial <scott+python-dev at scottdial.com<scott%2Bpython-dev at scottdial.com>
wrote:
>>> addr = ipaddr.IPAddress("10.1.2.3/255.255.240.0") ... ipaddr.IPAddressIPValidationError: '98.223.189.24/255.255.240.0' is not a valid address (hint, it's probably a network)
Because, it is a address of a host on a network. I gave in and said:
10.1.2.3 is the address of a host on a network. 255.255.240.0 is a subnet mask.
net = ipaddr.IPNetwork("10.1.2.3/255.255.240.0") But then, I was dumbfounded as to how I could get the gateway IP from this IPNetwork object. It took me a while to figure out that you can iterate over IPNetwork instances:
Any IP address on an IP network could be the gateway, so there is no reliable way to determine the gateway IP from the network address and subnet mask alone.
Technicalities aside, I agree with you that IPNetwork appears to be doing double-duty as an IPNetwork type and an IPAddressWithNetwork type, which I find confusing.
-- Daniel Stutzbach, Ph.D. President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20090915/c4898aaa/attachment.htm>
- Previous message: [Python-Dev] PEP 3144 review.
- Next message: [Python-Dev] PEP 3144 review.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]