Why Python don't accept 03 as a number?

Ian Kelly ian.g.kelly at gmail.com
Fri Dec 7 22:27:41 EST 2018


On Fri, Dec 7, 2018 at 7:47 PM <jfong at ms4.hinet.net> wrote:
>
> MRAB at 2018/12/8 UTC+8 AM10:04:51 wrote:
> > Before Python 3, a leading 0 in an integer literal would indicate an
> > octal (base 8) number.
>
> So, the reason is historical.
>
> > The old form is now invalid in order to reduce the chance of bugs.
>
> I encounter this problem on trying to do something like this:
>     eval('03 + 00 + 15')
> It takes me some efforts to get rid of those leading zeros:-(

What is it exactly that you're trying to accomplish with this? Perhaps
there's a better way than using eval.


More information about the Python-list mailing list