Leading 0's syntax error in datetime.date module (Python 3.6)

Chris Angelico rosuav at gmail.com
Thu May 10 20:11:33 EDT 2018


On Fri, May 11, 2018 at 8:43 AM, bartc <bc at freeuk.com> wrote:
> This is Wrong, and would have been just as obviously wrong in 1989.

Having spent many years programming in C and working on Unix, I
strongly disagree. This was *not* obviously wrong. It's easy to say
"but look at the real world"; but in the 80s and 90s, nobody would
have said that it was "obviously wrong" to have the native integer
wrap when it goes past a certain number of bits. And in fact, your
description of the real world makes it equally obvious that numbers
should have a fixed width:

> If my car odometer says 075300, it means I've done 75,300 miles or km, not 31424

You might actually have done 1,075,300 ticks, or 2,075,300, or any
other number that ends with those six digits. That's OBVIOUSLY right,
because you can look at your odometer or a pocket calculator and see
that numbers don't need to have infinite precision.

Octal makes a lot of sense in the right contexts. Allowing octal
literals is a Good Thing. And sticking letters into the middle of a
number doesn't make that much sense, so the leading-zero notation is a
decent choice. It's all very well to argue that it's a suboptimal
choice; but you have to remember that you're arguing that point from
2018, and we have about thirty years of experience using Python. The
choice was most definitely not fundamentally wrong. Ten years ago, the
point was revisited, and a different choice made. That's all.

ChrisA



More information about the Python-list mailing list