This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Deprecate 00000 as a synonym for 0
Type: behavior Stage:
Components: Versions: Python 3.6
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: cvrebert, georg.brandl, mark.dickinson, rhettinger, steven.daprano
Priority: normal Keywords:

Created on 2015-07-19 10:58 by steven.daprano, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (5)
msg246939 - (view) Author: Steven D'Aprano (steven.daprano) * (Python committer) Date: 2015-07-19 10:58
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.
msg246943 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2015-07-19 15:48
Since 0000 is unambiguous, I propose leaving this alone unless some actual harm can be shown.  The leading zeros for floats have proven to be harmless, 00.0 is valid.  I see no reason to churn the code, go through deprecation effort, burden the docs with a X-stopped-being-valid-in-version-Y.   

Unless Georg states that this was a flat-out mistake, I vote -1 based on there being insufficient motivation to undo an already released implementation decision.
msg246945 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2015-07-19 17:13
I don't recall the reason for this deliberate change (as seen from the docs change). 

I'm unable to come up with a good reason for this change now, but on the other hand I can't come up with a good reason for code churn and adding deprecationg warnings for a minor detail just as Raymond says.

Since the direction we're going is to allow leading zeros for all decimal literals in Python 4 (if it ever comes around), that's another reason for the status quo to win.
msg246946 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2015-07-19 17:40

> I propose leaving this alone unless some actual harm can be shown.

msg260117 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2016-02-11 17:24
Closing now.
Date User Action Args
2022-04-11 14:58:19adminsetgithub: 68856
2016-03-06 10:36:57berker.peksaglinkissue26490 superseder
2016-02-11 17:24:46georg.brandlsetstatus: pending -> closed

messages: + msg260117
2015-07-19 17:40:58mark.dickinsonsetstatus: open -> pending
2015-07-19 17:40:48mark.dickinsonsetstatus: pending -> open
nosy: + mark.dickinson
messages: + msg246946

2015-07-19 17:13:49georg.brandlsetstatus: open -> pending
resolution: rejected
messages: + msg246945
2015-07-19 15:48:35rhettingersetassignee: georg.brandl

messages: + msg246943
nosy: + georg.brandl, rhettinger
2015-07-19 11:08:18cvrebertsetnosy: + cvrebert
2015-07-19 10:58:37steven.dapranocreate