Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #53889

a gift function and a question

Subject a gift function and a question
From Mohsen Pahlevanzadeh <mohsen@pahlevanzadeh.org>
Date 2013-09-10 00:40 +0430
Newsgroups comp.lang.python
Message-ID <mailman.193.1378757469.5461.python-list@python.org> (permalink)

Show all headers | View raw


Dear all,

I have a gift for mailing list:

////////////////////////////////
def integerToPersian(number):
    listedPersian = ['۰','۱','۲','۳','۴','۵','۶','۷','۸','۹']
    listedEnglish = ['0','1','2','3','4','5','6','7','8','9']    
    returnList = list()
    
    listedTmpString = list(str(number))
    
    for i in listedTmpString:
        returnList.append(listedPersian[listedEnglish.index(i)])

    return ''.join(returnList)
////////////////////////////////////
When you call it such as : "integerToPersian(3455)" ,  it return ۳۴۵۵,
۳۴۵۵ is equivalent to 3455 in Persian and Arabic language.When you read
a number such as reading from databae, and want to show in widget, this
function is very useful.

My question is , do you have reverse of this function? persianToInteger?

Yours,
Mohsen

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

a gift function and a question Mohsen Pahlevanzadeh <mohsen@pahlevanzadeh.org> - 2013-09-10 00:40 +0430
  Re: a gift function and a question Steven D'Aprano <steve@pearwood.info> - 2013-09-10 07:01 +0000
    Re: a gift function and a question random832@fastmail.us - 2013-09-10 09:50 -0400
    Re: a gift function and a question Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-09-10 15:11 +0000

csiph-web