[New-bugs-announce] [issue24668] Deprecate 00000 as a synonym for 0

Steven D'Aprano report at bugs.python.org
Sun Jul 19 12:58:37 CEST 2015

New submission from Steven D'Aprano:

As discussed on the python-ideas list here:

Subject: Disallow "00000" as a synonym for "0"

and on Stackoverflow, leading zeroes are forbidden for ints, due to the possible confusion with C-style octal literals e.g. 007 raises syntax error. However, zero itself allows an arbitrary number of leading zeroes, e.g. 000 is accepted. Nobody seems to know why this special case was allowed in the first place, or come up with a use-case for it.

I propose deprecating this: 0 will be the one canonical way to write a zero int in base 10. 00 000 etc should raise a compile-time deprecation warning, to be eventually turned into a syntax error same as 01 002 etc. Float literals, string conversions, and bin/oct/hex literals will remain unchanged.

Cons: if there is anyone out there typing `000` when `0` will do, this will complain noisily.

Pros: cleaner syntax; some typos which may be silently accepted (`00` for `90`) will be caught.

messages: 246939
nosy: steven.daprano
priority: normal
severity: normal
status: open
title: Deprecate 00000 as a synonym for 0
type: behavior
versions: Python 3.6

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list