On Sunday, July 19, 2015 at 12:46:26 PM UTC+5:30, Marko Rauhamaa wrote: > Chris Angelico: > > > On Sun, Jul 19, 2015 at 2:45 PM, Steven D'Aprano 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:
Nice analogy > > >>> 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. But it is willy-nilly global. Python: >>> 4+5 9 >>> Unix bc: $ bc bc 1.06.95 Copyright 1991-1994, 1997, 1998, 2000, 2004, 2006 Free Software Foundation, Inc. This is free software with ABSOLUTELY NO WARRANTY. For details type `warranty'. 4+5 9 obase=8 4+5 11 IOW bc has two (global) variables ibase and obase for input and output base. If you dont provide these as settable you hardwire them at 10 (8/16 in some assembly languages)¹ Hopefully you will agree that python is more full-featured than bc and should subsume bc functionality? [Implementability is a second question and ease of implementability a third] I believe numeral-language is similar --- ¹ When Ive played around with writing assemblers for toy machines, the hardwired 10-base has often been a nuisance. Of course one can in principle rebuild an REPL. Repurposing the existing one is usually a far more palatable option (for me). -- https://mail.python.org/mailman/listinfo/python-list