Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Terry Reedy Newsgroups: comp.lang.python Subject: Re: Curious Omission In New-Style Formats Date: Mon, 11 Jul 2016 14:54:34 -0400 Lines: 53 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> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de IOXEXjV/DYtby4UFYdRhmQrr1wpfPXIvQIWDyiM4t7WA== 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; 'context': 0.05; 'means,': 0.07; 'trailing': 0.07; 'width': 0.07; 'degree,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'jan': 0.11; "'to": 0.16; '100,': 0.16; '2016': 0.16; 'count,': 0.16; 'digits.': 0.16; 'inclusive.': 0.16; 'integers.': 0.16; 'measurement': 0.16; 'nearest': 0.16; 'new-style': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'reedy': 0.16; 'statistics,': 0.16; 'wrote:': 0.16; 'integer': 0.18; '>>>': 0.20; 'math': 0.20; 'saying': 0.22; 'assuming': 0.22; 'am,': 0.23; 'seems': 0.23; 'header:In-Reply-To:1': 0.24; 'header :User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.26; 'specify': 0.27; "skip:' 10": 0.28; '120': 0.29; 'decimal': 0.29; 'thus,': 0.29; "i'm": 0.30; 'post': 0.31; 'says': 0.32; 'usually': 0.33; "d'aprano": 0.33; 'int': 0.33; 'steven': 0.33; 'case,': 0.34; "skip:' 20": 0.34; 'tue,': 0.34; 'that,': 0.34; 'could': 0.35; 'sometimes': 0.35; 'but': 0.36; 'to:addr:python-list': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'say': 0.37; 'received:org': 0.37; 'seem': 0.37; 'things': 0.38; 'mean': 0.38; 'does': 0.39; 'subject:-': 0.39; 'rather': 0.39; 'to:addr:python.org': 0.40; 'field': 0.60; 'leading': 0.61; 'skip:u 10': 0.61; 'course': 0.62; 'received:96': 0.63; 'limit': 0.65; 'jul': 0.72; 'upper': 0.76; '100': 0.79; 'counts': 0.81; 'gain': 0.82; 'confusion.': 0.84; 'learn.': 0.84; 'maths': 0.84; 'ethan': 0.91; 'furman': 0.91; 'received:fios.verizon.net': 0.91; 'improvement': 0.93; 'hundred': 0.96 X-Injected-Via-Gmane: http://gmane.org/ X-Gmane-NNTP-Posting-Host: pool-96-227-207-81.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 In-Reply-To: <5783D63F.5040307@stoneleaf.us> 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: 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> Xref: csiph.com comp.lang.python:111284 On 7/11/2016 1:24 PM, Ethan Furman wrote: > On 07/11/2016 09:28 AM, Steven D'Aprano wrote: >> On Tue, 12 Jul 2016 01:04 am, Ian Kelly wrote: > >> Er, what? I count *five* digits in "00123", not three. >> >> You seem to be assuming that "precision" can only refer to digits >> after the >> decimal place, but that's a dubious proposition. > > I will readily admit to not having a maths degree, and so of course to > me saying the integer 123 has a precision of 5, 10, or 99 digits seems > like hogwash to me. I do have an undergraduate degree in math and a career in statistics, and I cannot remember seen 'precision' used in relation to integers. So I would call it a 'non-standard extension' of the notion. > But I'm always willing to learn. So please explain what 123 with a > precision of five integer digits means, What it could mean is that we have an count selected from the range 00000 to 99999 inclusive. But what I just said is the usual way of saying that, as it does not limit the lower and upper limits to 0s and 9s. > and what to do we gain by saying such a thing? Confusion. Precision is usually used in reference to measurement, and while measurement is based on counting, it is not the same thing. If 123 is a count, then its precision is 1 count, not k digits. Or one could say that all digits are precise. What is ambiguous without context is whether counts with trailing 0s, like 120 or 100 are exact or rounded. 100, as a cound, could have a precision of 1, 2, or 3 (significant) digits. Context sometimes says things like 'to the nearest hundred thousand'. In any case, I think it an improvement to say that '0x00123' has a field width of 7 rather than a 'precision' of 5. >>> '{:#07x}'.format(0x123) # specifiy field width '0x00123' >>> "%#0.5x" % 0x123 # specify int precision '0x00123' Thus, my title for a post noting the same change might be "Upgrade in new-style formats". (format and If one want leading 0s, -- Terry Jan Reedy