[Python-Dev] PEP 3144 review. (original) (raw)
"Martin v. Löwis" martin at v.loewis.de
Mon Sep 28 21:52:53 CEST 2009
- Previous message: [Python-Dev] PEP 3144 review.
- Next message: [Python-Dev] PEP 3144 review.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
The fundamental divide here is between two behaviors.
ipaddr: >>> x = IPv4Network('192.168.1.1/24') >>> y = IPv4Network('192.168.1.0/24') >>> x == y False >>> x.ip IPv4Address('192.168.1.1') desired: >>> x = IPv4Network('192.168.1.1/24') >>> y = IPv4Network('192.168.1.0/24') >>> x == y True >>> x.ip Traceback (most recent call last): File "", line 1, in AttributeError: 'IPv4Network' object has no attribute 'ip'
I can understand the debate around the comparison.
I cannot understand the complaint that networks where the base address is not null-terminated should be banned, or useless (which was the original concern that I responded to).
Everything else is pretty much bikeshedding and can be dealt with. This is fundamental and Peter has indicated he will not change it.
I can see why either behavior is desirable (i.e. comparison should either use the specified address, or the network address); following the Python Zen, we should refuse the temptation to guess.
Unfortunately, that would mean that we should provide two comparison operations, and have neither available as == (unless one is more clearly right than the other, which I'm skeptical about).
Regards, Martin
- Previous message: [Python-Dev] PEP 3144 review.
- Next message: [Python-Dev] PEP 3144 review.
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]