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

Steven D'Aprano steve at
Sun Jul 19 06:45:11 CEST 2015

On Sun, 19 Jul 2015 01:52 pm, Rustom Mody wrote:

> Not to mention actively hostile attitude to discussions that could at the
> moment be tangential to current CPython. See (and whole thread)

I stand by my comments there. I have no disagreement with your aim to build
a specialised language for teaching functional programming. I don't believe
that should be Python.

> JFTR: My kids (um... students) have just managed to add devanagari
> numerals to python.
> ie we can now do
>>>> १ + २
> 3

That is actually quite awesome, and I would support a new feature that set
the numeric characters to a particular script, e.g. Latin, Arabic,
Devanagari, whatever, and printed them in that same script. It seems
unfortunate that १ + २ prints as 3 rather than ३.

Python already, and has for many years, supported non-ASCII digits in string
conversions. This is in Python 2.4:

py> int(u'१२')
py> float(u'.१२')

so the feature goes back a long time.

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. 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.:


I would support this, or something like this, as a language feature. If we
can write Python using Hindi identifiers, why not Hindi numerals?

> Regarding this as a fork of python is technically (legalistically) correct
> but pragmatically ridiculous [unless my students spell as 'Linus Torvalds'
> or somethin...].

There's a grey area between a fork and a local patch. Ever fork begins as a
local patch. It only becomes a fork if you go public with it, give it a new
name, etc. Forks can be highly respected, e.g. Stackless is a fork of


More information about the Python-list mailing list