On 2015-07-19 14:45, Steven D'Aprano wrote: >> 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'१२') > 12 > py> float(u'.१२') > 0.12 > > so the feature goes back a long time.
Agreed that it's pretty awesome. It seems to have some holes though: Python 3.4.2 (default, Oct 8 2014, 10:45:20) [GCC 4.9.1] on linux Type "help", "copyright", "credits" or "license" for more information. >>> print('\N{VULGAR FRACTION ONE EIGHTH}') ⅛ >>> print(float('\N{VULGAR FRACTION ONE EIGHTH}')) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: could not convert string to float: '⅛' >>> print('\N{ROMAN NUMERAL NINE}') Ⅸ >>> int('\N{ROMAN NUMERAL NINE}') Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: invalid literal for int() with base 10: 'Ⅸ' >>> print('\N{ROMAN NUMERAL TEN THOUSAND}') ↂ >>> int('\N{ROMAN NUMERAL TEN THOUSAND}') Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: invalid literal for int() with base 10: 'ↂ' -tkc -- https://mail.python.org/mailman/listinfo/python-list