[Python-Dev] conceptual clarity
R. David Murray
rdmurray at bitdance.com
Thu Sep 17 20:04:11 CEST 2009
On Thu, 17 Sep 2009 at 10:38, Peter Moody wrote:
> On Thu, Sep 17, 2009 at 10:32 AM, R. David Murray <rdmurray at bitdance.com> wrote:
>> On Thu, 17 Sep 2009 at 09:16, Peter Moody wrote:
>>> I mentioned before that IPy's insistence on receiving masked out
>>> networks was one of the main reasons I wrote ipaddr to begin with.
>>> Having ipaddr mimic this behavior would make it significantly less
>>> useful. Removing functionality in the name of avoiding confusion
>>> doesn't make sense when the same confusion can be alleviated w/o the
>> We're suggesting moving that functionality (accepting a non-masked IP
>> plus netmask and returning the corresponding Network object) into
>> a different constructor, not eliminating the functionality.
> Do you mean a new constructor function, ala IPAddress and IPNetwork
> (so the current classes remain largely the same and the various
> constructors enforce certain restrictions) or something else?
> At this point, I'm getting confused with the intermingling of class
> and constructor names.
I mean, eg, IPv4Network.fromHostIP('192.168.1.1/24').
Or some such name.
Having another constructor that took an IPv4Address object and a mask
would probably be a good idea as well. These could be exposed as
appropriately named module level functions instead/as well, of course.
I would have IPv4Address itself be strict, and thus the new constructors
would compute the network address and call the regular IPv4Address
(*) If that's the part you object to (not recording the input IP
in the Network object), then clearly you see a need to have an
AddressWithMask object of _some_ sort....
More information about the Python-Dev