[Python-ideas] Disallow "00000" as a synonym for "0"

Ron Adam ron3200 at gmail.com
Sat Jul 18 21:40:28 CEST 2015



On 07/17/2015 11:22 AM, Steven D'Aprano wrote:
> On Fri, Jul 17, 2015 at 10:28:19AM -0400, Eric V. Smith wrote:
>> >On 07/16/2015 06:15 AM, Neil Girdhar wrote:
>>> > >As per this
>>> > >question:http://stackoverflow.com/questions/31447694/why-does-python-3-allow-00-as-a-literal-for-0-but-not-allow-01-as-a-literal
>>> > >
>>> > >It seems like Python accepts "000000000" to mean "0".  Whatever the
>>> > >historical reason, should this be deprecated?
>> >
>> >No. It would needlessly break working code.
> I wonder what working code uses 00 when 0 is wanted? Do you have any
> examples? I believe that anyone writing 00 is more likely to have made
> a typo than to actually intend to get 0.
>
> In Python 2, 00 has an obvious and correct interpretation: it is zero in
> octal. But in Python 3, octal is written with the prefix 0o not 0.

And then there is this...

 >>> 000.0
0.0
 >>> 000.1
0.1

Cheers,
    Ron




More information about the Python-ideas mailing list