[Python-Dev] PEP 3144 review.
scott+python-dev at scottdial.com
Wed Sep 16 01:38:40 CEST 2009
Sebastian Rittau wrote:
> On Tue, Sep 15, 2009 at 01:16:06PM -0400, Scott Dial wrote:
>>>>> 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.
> Well, you can't. There is no way to determine a gateway, without querying
> the network topology. This is clearly outside the scope of this module.
> The only two known host addresses of a network are the network address
> (10.1.0.0 in the example you gave) and the broadcast address (10.1.15.255).
I was not writing a general utility for the world to use. On *my*
network it is always the th address used for the gateway. But, I
agree in general that is not true.
>> Which sorta blew my mind.. I fully expected to receive an IPNetwork back
>> from that operation. It is unclear to me why the network information
>> gets chucked by that operation.
> This makes perfect sense to me. An IP network consists of a list of IP
> addresses. Returning /32 networks seems kind of pointless to me.
As I clarified later, I expected it to still be a /24 network, not a
/32. /32 makes no sense.
> But a gateway is not an IP address plus hostmask. A gateway is just a single
> IP address. What is the use of adding a hostmask to the gateway IP address
> or some other IP address inside the network?
My argument was from a destruction of information standpoint. Why is the
network chucked away? Wouldn't it be handy to be able to inspected
addr.network to see what network it was on? Perhaps because you are
building routing rules and need to actually know that. As it is, you
will just have to build your own IPAddressWithNetwork objects.
Hopefully I have covered all of you inquiries, but I feel like that a
lot of this is covered by many other replies in this thread.
scott at scottdial.com
scodial at cs.indiana.edu
More information about the Python-Dev