[Python-3000] Fwd: Re: Fwd: Re: Octal

Patrick Maupin pmaupin at gmail.com
Wed Mar 14 22:24:31 CET 2007


> Leading zeroes are not a syntax error.  Excel supports them for both input and output formats because accountants (like me) ocassionally need them. Schoolkids have an expectation that leading zeroes do not change the value.  Your pocket calculator accepts leading zeroes.  I do not support adding yet another SyntaxError to the language -- that will not improve its ease of use.  With decimal and float literals supporting lead zeroes, it would be a wart to introduce a syntax error for ints.

I agree that, in a perfect world, these numbers would be considered
decimal.   But when it comes to backwards compatibility, it is
interesting you mention Excel -- there seems to be another thread
going on about its CSV parsing :)

> >In fact, I would go so far as to argue that the behavior of int()
> >should be changed as well:
> >
> >    int('012')       -> exception (used to return 12)
>
> Gratuitous breakage.
> Major inconvenience when parsing zfilled inputs (which are ubiquitous).
>
>     hour, minutes, seconds = map(int, '08:30:00'.split(':'))

I can agree that should stay, since it has been there all along giving
the "right" answer, but I particularly don't want int('012', 0) to
return 12 and not throw an exception, since it has been giving the
"wrong" answer all along.

Pat


More information about the Python-3000 mailing list