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


Groups > comp.lang.python > #53904

Re: a gift function and a question

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <mohsen@pahlevanzadeh.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.018
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'constructor': 0.09; 'subject:question': 0.10; 'cc:addr:python-list': 0.11; 'def': 0.12; '16:10,': 0.16; 'function?': 0.16; 'skip:[ 40': 0.16; 'skip:[ 50': 0.16; 'wrote:': 0.18; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'skip:l 30': 0.24; 'mon,': 0.24; 'question': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'skip:p 30': 0.29; "skip:' 10": 0.31; 'decimal': 0.31; 'sep': 0.31; 'two': 0.37; 'handle': 0.38; 'completed': 0.61; 'different': 0.65; 'reverse': 0.68; 'skip:r 30': 0.69; '2013,': 0.91
DKIM-Signature v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=pahlevanzadeh.org; s=default; h=Content-Transfer-Encoding:Mime-Version:Content-Type:References:In-Reply-To:Date:Cc:To:From:Subject:Message-ID; bh=GM4aFl7qbUz1Wo/UgkLI09A+1Tl3j9HvVPoHKYhgxcc=; b=BYvV+VzKDCxniYLNWJnFSnAL8iAe0vU+8609ePQgqOG/9ZhQA8f8HcePRiqmMN7h1FwieFh2TicHmmVjOTuXoLzEiZ6xoY0hm97jmbIw0t/PHOvymXBDr0P4mz90AP33/d63xAF0juXTIqJugHu2QbJBcSCH7LKJNmwSWR5rIBw=;
Subject Re: a gift function and a question
From Mohsen Pahlevanzadeh <mohsen@pahlevanzadeh.org>
To random832@fastmail.us
Date Tue, 10 Sep 2013 10:56:19 +0430
In-Reply-To <1378758025.32118.19881065.6BD771B7@webmail.messagingengine.com>
References <1378757459.6005.55.camel@debian> <1378758025.32118.19881065.6BD771B7@webmail.messagingengine.com>
Content-Type text/plain; charset="UTF-8"
X-Mailer Evolution 3.4.4-4+b1
Mime-Version 1.0
Content-Transfer-Encoding 8bit
X-AntiAbuse This header was added to track abuse, please include it with any abuse report
X-AntiAbuse Primary Hostname - part7.royal-servers.com
X-AntiAbuse Original Domain - python.org
X-AntiAbuse Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse Sender Address Domain - pahlevanzadeh.org
X-Get-Message-Sender-Via part7.royal-servers.com: authenticated_id: mohsen@pahlevanzadeh.org
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.200.1378794396.5461.python-list@python.org> (permalink)
Lines 35
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1378794396 news.xs4all.nl 15953 [2001:888:2000:d::a6]:47531
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:53904

Show key headers only | View raw


I completed my two functions, i say may be poeple can use them:
######################################33         
def integerToPersian(number):
    listedPersian = ['۰','۱','۲','۳','۴','۵','۶','۷','۸','۹']
    listedEnglish = ['0','1','2','3','4','5','6','7','8','9']    
    returnList = list()
           
    for i in list(str(number)):
        returnList.append(listedPersian[listedEnglish.index(i)])

    return ''.join(returnList)

def persianToInterger(persianNumber):
    listedTmpString = list(persianNumber.decode("utf-8"))
    returnList = list()
    
    for i in listedTmpString:
        returnList.append(unicodedata.digit(i))
        
    return int (''.join(str(x) for x in returnList))
#######################################33



On Mon, 2013-09-09 at 16:20 -0400, random832@fastmail.us wrote:
> On Mon, Sep 9, 2013, at 16:10, Mohsen Pahlevanzadeh wrote:
> > My question is , do you have reverse of this function? persianToInteger?
> 
> The int constructor is able to handle different forms of decimal
> numerals directly:
> 
> >>> int('\u06f3\u06f4\u06f5\u06f5')
> 3455

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


Thread

Re: a gift function and a question Mohsen Pahlevanzadeh <mohsen@pahlevanzadeh.org> - 2013-09-10 10:56 +0430

csiph-web