Message 88692 - Python tracker (original) (raw)
In pre-CIDR days, assuming a prefixlen of 24 for a 192.168.x.x address made sense. Nowadays it is better not to make that assumption. So I find ipaddr's default of 32 to be "safer" than using a class based default.
The larger point, however, is that there is a mask associated with the address in ifconfig. There must be one. So that is not an example that shows that a separate address class is useful.
As for the == thing, I agreed with you that address compared to network, if you had an address class, would yield false. My point was that
HypotheticalNetworkClass('192.168.1.1') ==
HypotheticalNetworkClass('192.168.1.1/32')
should yield True, because, as I said above, in a CIDR world using a default of a hostmask for an otherwise unadorned address makes the most sense.
As for an example of when the equivalence is useful, it is useful every time I set up an access rule or route that applies to a single host. Otherwise, I must give a specific netmask, because in real life the classfull default is often not the correct netmask. Most networking software that I've dealt with requires explicit netmasks (often with a shorthand to specify an ip/hostmask pair). It is true that when a netmask isn't required it generally defaults to the classful netmask, but having such a default is becoming more rare with time, in my experience (because of CIDR).