Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: Random832 Newsgroups: comp.lang.python Subject: Re: What is precision of a number representation? Date: Tue, 12 Jul 2016 09:36:27 -0400 Lines: 15 Message-ID: References: <834b1cce-38dd-474c-8915-4ff1cd6b27ec@googlegroups.com> <7fcc8c21-106f-41d4-a5ba-409f3b54a56d@googlegroups.com> <5783c91e$0$1622$c3e8da3$5496439d@news.astraweb.com> <5783D63F.5040307@stoneleaf.us> <8560sbvqqd.fsf_-_@benfinney.id.au> <57841AE9.3090508@stoneleaf.us> <57848c74$0$11093$c3e8da3@news.astraweb.com> <1468330587.480682.663966945.2D4D33CE@webmail.messagingengine.com> Mime-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de aa4N5gEYzvmYvfLLRNe99ge9g09coMW3mD6qvcaf1S1g== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:number': 0.07; 'received:internal': 0.09; 'output': 0.13; '"format': 0.16; '(well,': 0.16; 'message-id:@webmail.messagingengine.com': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:io': 0.16; 'received:messagingengine.com': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'not,': 0.22; 'latter': 0.22; 'header:In- Reply-To:1': 0.24; "i've": 0.25; 'about.': 0.29; 'fixed': 0.31; "d'aprano": 0.33; 'steven': 0.33; 'tue,': 0.34; 'this?': 0.34; 'something': 0.35; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; '12,': 0.37; 'received:66': 0.38; 'to:addr:python.org': 0.40; 'header:Message- Id:1': 0.61; 'jul': 0.72 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-sasl-enc :x-sasl-enc; s=mesmtp; bh=S9QORbYQkGArxv6sM+gmKBdGHl8=; b=ldJbZK X8t1WNNwYSexZyWMZW7rttm7GsFkb9WRIQkQMtemV31wT2iO+/B1akFnJLYbUdE6 C+4Tr+LibvowTD4/3Z7XPNKtAMOcjWNaGkxP/H9t7FGK9yDvh4ouNVB+T8L2MuE6 tZwRc7u/9BtrlnHAoSt8Syk8K3VNRa7MbY84E= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=S9QORbYQkGArxv6 sM+gmKBdGHl8=; b=pAxpd1DgdClU/4HbZzUkS4RTP0sbQMN0uPMqU6/qZ1Tgc19 wgtzLEXFU7mQQERdtbZSNEkQnV2YUE/gwXjwVa4/r+Fmty4ojuEB2oLTK/KCaS3X tdfYq0aIs6lbux5MCAeYDU99PFB84E91NPFP+NxTIx+uz1gW9BzSsheSaMAQ= X-Sasl-Enc: D+HeAQrNQIow0/IeCCPj3CDtWHVlQIM33lNAHXqvmnko 1468330587 X-Mailer: MessagingEngine.com Webmail Interface - ajax-c65b75c9 In-Reply-To: <57848c74$0$11093$c3e8da3@news.astraweb.com> X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <1468330587.480682.663966945.2D4D33CE@webmail.messagingengine.com> X-Mailman-Original-References: <834b1cce-38dd-474c-8915-4ff1cd6b27ec@googlegroups.com> <7fcc8c21-106f-41d4-a5ba-409f3b54a56d@googlegroups.com> <5783c91e$0$1622$c3e8da3$5496439d@news.astraweb.com> <5783D63F.5040307@stoneleaf.us> <8560sbvqqd.fsf_-_@benfinney.id.au> <57841AE9.3090508@stoneleaf.us> <57848c74$0$11093$c3e8da3@news.astraweb.com> Xref: csiph.com comp.lang.python:111335 On Tue, Jul 12, 2016, at 02:21, Steven D'Aprano wrote: > If not, then what are the alternatives? Using str.format, how would > you get the same output as this? > > > py> "%8.4d" % 25 > ' 0025' " %04d" % 25 "%8s" % ("%04d" % 25) The latter (well, generally, "format it how you want and then use %*s to put it in fixed columns") is something that I've actually *done*, because it's easier to reason about.