[Python-Dev] PEP 3144 review. (original) (raw)
Scott Dial scott+python-dev at scottdial.com
Wed Sep 16 01:34:09 CEST 2009
- Previous message: [Python-Dev] PEP 3144 review.
- Next message: [Python-Dev] PEP 3144 review.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
R. David Murray wrote:
On Tue, 15 Sep 2009 at 21:58, Antoine Pitrou wrote:
Le mardi 15 septembre 2009 à 15:48 -0400, R. David Murray a écrit :
However, I do not think that the proposed API should accept, eg, IPv4Network('192.168.1.1/24') as valid. That's just too confusing and error prone.
Indeed, it should throw some kind of ValueError instead. Peter, what do you think?
This change would have to be dependent on Antoine's suggestion of:
>>> addr, net = parse_address_with_mask('192.168.1.1/24')
>>> addr == IPv4Address('192.168.1.1')
True
>>> net == IPv4Network('192.168.1.0/24')
True
Otherwise, I am ok with this change too. It resloves the weird duality of IPv4Network. And as RDM says, anyone who wants the IPv4AddressWithNetwork functionality can just role it themselves. At the moment of iteration, you have access to what network it is and can build your own IPv4AddressWithNetwork objects.
net = IPv4Network('10.0.0.0/24') netaddrs = [] for addr in net: netaddrs.append(IPv4AddressWithNetwork(addr, net))
I guess I am ok with this. It seems sub-optimal (why not just return a IPv4AddressWithNetwork to begin with?) but I suppose it is no less efficient since the same objects would be constructed.
-- Scott Dial scott at scottdial.com scodial at cs.indiana.edu
- Previous message: [Python-Dev] PEP 3144 review.
- Next message: [Python-Dev] PEP 3144 review.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]