Devanagari int literals [was Re: Should non-security 2.7 bugs be fixed?]

Chris Angelico rosuav at
Sun Jul 19 07:06:49 CEST 2015

On Sun, Jul 19, 2015 at 2:45 PM, Steven D'Aprano <steve at> wrote:
> I think that Python should allow int and float literals using any sequences
> of digits from the same language, e.g. 12 or १२ but not १2.

I would agree with this. Actually, given that int("१२") works just
fine, I was surprised that it didn't already work in syntax.

> One might have
> an interpreter hook which displayed ints and floats using non-ASCII digits,
> or one might even build that function into the intepreter, e.g. have a
> global setting which tells ints and floats what digits to use, e.g.:
> sys.setdigits('Devanagari')

Easiest way to play with this would be a sys.displayhook, I think; I
suspect it would be problematic to change int.__str__ or int.__repr__.
But for interactive work, yep, definitely, it should be easy enough to
make int and float display appropriately.


More information about the Python-list mailing list