On Tue, 10 Sep 2013 07:01:20 +0000, Steven D'Aprano wrote: > On Tue, 10 Sep 2013 00:40:59 +0430, Mohsen Pahlevanzadeh wrote:
>> My question is , do you have reverse of this function? >> persianToInteger? > > The Python built-in int function already supports that: > > > py> int('۳۴۵۵') > 3455 Oh, I forgot to mention, this works back to at least Python 2.4, provided you remember to use Unicode strings rather than bytes: py> b = '۳۴۵۵' # This fails. py> int(b) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: invalid literal for int() with base 10: '\xdb\xb3\xdb\xb4\xdb \xb5\xdb\xb5' py> py> s = u'۳۴۵۵' # This works. py> int(s) 3455 -- Steven -- https://mail.python.org/mailman/listinfo/python-list