[Python-Dev] conceptual clarity

Sebastian Rittau srittau at jroger.in-berlin.de
Fri Sep 18 02:24:23 CEST 2009


On Thu, Sep 17, 2009 at 02:04:11PM -0400, R. David Murray wrote:

> I mean, eg, IPv4Network.fromHostIP('192.168.1.1/24').

I'd actually suggest to use

  >>> net, host = parse_network_and_host("192.168.111.33/24")
  (IPv4Network('192.168.111.0/24'), IPv4Address('192.168.111.33'))
  >>> 

I think this helps the use case of the short network+gateway notation,
while keeping the concepts of network and host address cleanly separate.

> I would have IPv4Address itself be strict, and thus the new constructors
> would compute the network address and call the regular IPv4Address
> constructor.(*)

Then the regular IPv4Network constructor could be strict and can be used
for validation.

 - Sebastian


More information about the Python-Dev mailing list