New submission from Steven D'Aprano:

As discussed on the python-ideas list here:

Subject: Disallow "00000" as a synonym for "0"
https://mail.python.org/pipermail/python-ideas/2015-July/034631.html

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 <rep...@bugs.python.org>
<http://bugs.python.org/issue24668>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to