On Thu, 15 Feb 2018 15:14:03 +1100, Steven D'Aprano wrote:

> On Thu, Feb 15, 2018 at 11:45:46AM +1100, Chris Angelico wrote:
>> Except that this computer's IPv4 is not 3232235539, and I never want
>> to enter it that way. I enter it as - as four separate
>> integers.
> That's partly convention (and a useful convention: it is less error- 
> prone than 3232235539) and partly that because you're a sys admin who 
> can read the individual subfields of an IP address. I'm not suggesting 
> you ought to change your habit.
> But to civilians, is as opaque as 3232235539 or 0xC0A80013 
> would be.

There was a lengthy discussion (or more than one) about supporting
decimal unicode code point literals.  Is U+03B1 (GREEK SMALL LETTER
ALPHA) somehow less clear than X+945? speaks volumes, but 3232235539 is not only opaque, but also

> But doing *at least some* int operations on addresses isn't meaningless:
> py> a = ipaddress.ip_address('')
> py> a + 1
> IPv4Address('')

py> a = ipaddress.ip_address('')
> py> a + 1
> IPv4Address('')

Uh, oh.

py> a = ipaddress.ip_address('')
> py> a + 1


Yes, if I were writing a DHCP server, the notion of "the next IP address
that meets certain constraints, or an exception if no such address
exists" has meaning.  But it's not as simple as "ip + 1."


Python-ideas mailing list
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to