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

Marko Rauhamaa marko at pacujo.net
Sun Jul 19 09:16:09 CEST 2015


Chris Angelico <rosuav at gmail.com>:

> On Sun, Jul 19, 2015 at 2:45 PM, Steven D'Aprano <steve at pearwood.info> wrote:
>> sys.setdigits('Devanagari')
>
> Easiest way to play with this would be a sys.displayhook, I think;

I think the numeral selection is analogous to the number base:

   >>> 0o10
   8
   >>> "{:o}".format(0o10)
   '10'

what we need is:

   >>> "{:d/base({base})}".format(0o10, base=7)
   '11'
   >>> "{:d/numeral('{num}')".format(0o10, num="European")
   '8'
   >>> "{:d/numeral('{num}')".format(0o10, num="Roman")
   'VIII'
   >>> "{:d/numeral('{num}')".format(0o10, num="RomanLowerCase")
   'viii'
   >>> "{:d/numeral('{num}')".format(0o10, num="EasternArabic")
   '٨'
   >>> "{:d/numeral('{num}')".format(0o10, num="Devanagari")
   '८'

IOW, don't make it global.


Marko


More information about the Python-list mailing list