Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'algorithm': 0.04; 'received:134': 0.05; '(python': 0.07; 'string': 0.09; 'lst': 0.09; 'subject:few': 0.09; 'python': 0.11; 'def': 0.12; 'displayed.': 0.16; 'integer,': 0.16; 'nick': 0.16; 'notation': 0.16; 'numeral': 0.16; 'wrote:': 0.18; 'print': 0.22; 'header :User-Agent:1': 0.23; 'header:In-Reply-To:1': 0.27; 'along': 0.30; 'moment': 0.34; 'display': 0.35; 'something': 0.35; 'but': 0.35; 'false': 0.36; 'so,': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'negative': 0.60; 'number,': 0.60; 'such': 0.63; 'choose': 0.64; 'code):': 0.84; 'pardon': 0.84 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqEEAOkeu1GGuA9G/2dsb2JhbABahwG4WYMCgRuDFwEBBAEjDwFFBgsJAhgCAgUWCwICCQMCAQIBRRMIAogEBo1bmz2JPYgHgSaOKRaCNoEUA5dBhgyLNoMR Date: Fri, 14 Jun 2013 15:52:38 +0200 From: Antoon Pardon User-Agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.12) Gecko/20130116 Icedove/10.0.12 MIME-Version: 1.0 To: python-list@python.org Subject: Re: A few questiosn about encoding References: <6dfa3707-80f4-407a-a109-66dbb0130513@googlegroups.com> <51b83e5a$0$29998$c3e8da3$5496439d@news.astraweb.com> <51b90ead$0$29997$c3e8da3$5496439d@news.astraweb.com> <51b9708b$0$29872$c3e8da3$5496439d@news.astraweb.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 42 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1371217960 news.xs4all.nl 15891 [2001:888:2000:d::a6]:54411 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:48148 Op 14-06-13 14:59, Nick the Gr33k schreef: > On 14/6/2013 1:50 μμ, Antoon Pardon wrote: >> Python works with numbers, but at the moment >> it has to display such a number it has to produce something >> that is printable. So it will build a string that can be >> used as a notation for that number, a numeral. And that >> is what will be displayed. > so a number is just a number but when this number needs to be displayed > into a monitor, then the printed form of that number we choose to call > it a numeral? > So, a numeral = a string representation of a number. Is this correct? Yes, when you print an integer, what actually happens is something along the following algorithm (python 2 code): def write_int(out, nr): ord0 = ord('0') lst = [] negative = False if nr < 0: negative = True nr = -nr while nr: digit = nr % 10 lst.append(chr(digit + ord0)) nr /= 10 if negative: lst.append('-') lst.reverse() if not lst: lst.append('0') numeral = ''.join(lst) out.write(numeral) -- Antoon Pardon