Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!newsfeed.straub-nv.de!weretis.net!feeder4.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!bcyclone05.am1.xlned.com!bcyclone05.am1.xlned.com!newsfeed.xs4all.nl!newsfeed4.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.020 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'expression:': 0.09; 'subject:2.7': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'repr()': 0.16; 'str()': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'trying': 0.19; 'cc:addr:python.org': 0.22; 'precise': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'message- id:@mail.gmail.com': 0.30; 'gives': 0.31; "skip:' 10": 0.31; 'received:google.com': 0.35; 'useful': 0.36; 'pm,': 0.38; 'you.': 0.62; 'subject:more': 0.64; 'more': 0.64; '2015': 0.84; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=7C1MmNB3giEJg7R8d5My37oT24fVrPTFJ7oivUtI1lc=; b=JVwc75UIqZAyZc/HUY+lKo7UDXmol/yxgbexfUQesI7vJGbcWyhKkdji/e87ZPPNCw hOfFZitYC8477/l7cfSNmA4gvY1ydKVMXqiR01oheWeQrL86lUcRitamxmxcLk2ZykF6 1lKwq0s8wuUcnbqyToRU25EZtfqw/vGSC6MDEfg7oz5bbwxtZGXlh2SxJM83abM751W9 moDrGp74fg+wn4S/o1LvF5grCts54Oryij96rzVUWGXDrDpndFHq/hltXc2A7o1Cx/SY DJXStr1xZxOSSh3dlC44u7yrVlJFU9QxC6ou1Cp/yIUqFptReVAKn8jaQZ5XDLBckVBj WwVQ== MIME-Version: 1.0 X-Received: by 10.50.176.137 with SMTP id ci9mr3655940igc.2.1430308527575; Wed, 29 Apr 2015 04:55:27 -0700 (PDT) In-Reply-To: <87twvzch2u.fsf@Equus.decebal.nl> References: <87twvzch2u.fsf@Equus.decebal.nl> Date: Wed, 29 Apr 2015 21:55:27 +1000 Subject: Re: str more precise in 3 as 2.7 From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ 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: 18 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1430308536 news.xs4all.nl 2902 [2001:888:2000:d::a6]:37843 X-Complaints-To: abuse@xs4all.nl X-Received-Bytes: 3373 X-Received-Body-CRC: 3366386987 Xref: csiph.com comp.lang.python:89543 On Wed, Apr 29, 2015 at 9:24 PM, Cecil Westerhof wrote: > I am trying to make my modules also work under Python 3. I found that > str is more precise in Python 3. The expression: > str(134 / 6.0) > gives in 2.7.8: > '22.3333333333' > and in 3.4.1: > '22.333333333333332' > > Was not very hard to solve: > if python_version == 3: > output06[5] = '22.333333333333332' > output10[5] = '23.333333333333332' > output10[8] = '24.77777777777778' Try using repr() instead of str() - it might be more useful to you. ChrisA