Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Ian Kelly Newsgroups: comp.lang.python Subject: Re: Curious Omission In New-Style Formats Date: Mon, 11 Jul 2016 09:04:22 -0600 Lines: 30 Message-ID: References: <834b1cce-38dd-474c-8915-4ff1cd6b27ec@googlegroups.com> <7fcc8c21-106f-41d4-a5ba-409f3b54a56d@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de 2WxTEfi0dbmNWX/JGXtwjQ0MgAol0kU0IfNfl9b/zOMg== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'cc:addr:python-list': 0.09; 'formatted': 0.09; 'integers': 0.09; 'separately': 0.09; 'width.': 0.09; 'syntax': 0.13; 'result.': 0.15; '2016': 0.16; 'cc:name:python': 0.16; 'digits.': 0.16; 'formats,': 0.16; 'precision.': 0.16; 'printf-style': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'sense,': 0.16; 'url:linux': 0.16; 'wrote:': 0.16; 'example.': 0.18; 'integer': 0.18; '>>>': 0.20; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'lawrence': 0.22; 'sat,': 0.23; 'this:': 0.23; 'header:In-Reply-To:1': 0.24; "doesn't": 0.26; 'example': 0.26; 'sense': 0.26; 'message- id:@mail.gmail.com': 0.27; 'format,': 0.27; 'specify': 0.27; 'e.g.': 0.30; 'except': 0.34; 'received:google.com': 0.35; 'done': 0.35; 'but': 0.36; 'there': 0.36; 'url:org': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'being': 0.37; 'wanted': 0.37; 'format': 0.39; 'does': 0.39; 'subject:-': 0.39; 'still': 0.40; 'field': 0.60; 'url:3': 0.60; 'your': 0.60; 'jul': 0.72; 'to:none': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:cc :content-transfer-encoding; bh=rFAL3PUQHt/Pt2psON4CPN6GGGkAQYzuhyUO8j8rrv0=; b=eMiEe3Kc6GfzeUQ9JonemqBDvaYW336P3vm05zzUve2skw8UCWm1B0T39QA4R0X53u f7prNrxZqu2nEgJRCwAzDI9c8pVroXG1OSnBt3sw6DOlcuJMGtMQA/SOEwePpjiWAIQ5 zRt9dheMA+cnX5GJcMeLOk4rn58D0eF16JFIxArBr+FodueFbdvJW5+8cLqE/61AdPfY 3ZOB8ejFKnn/qgBu19KqiBN62oxpFYdrQBTO8W3fcJsBh66pR8/+K8o9f7J53Z5USWXS wWiYF6C8zI6DAgpDfelgnGWIfw1xPnK8e7uhBZ3GX5tJ/nilzsKFNDzwiSZB9nXfDMr5 OhUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:cc:content-transfer-encoding; bh=rFAL3PUQHt/Pt2psON4CPN6GGGkAQYzuhyUO8j8rrv0=; b=QHCUR+oqzAliwZqySEpeXFcrxffyqMWGwpaCKQsQ1eedM2ti6R41dLdiCne3LbBbW9 9OzKbvq9HwIcLacfVW/o+sCbYUqHA2fXFXb6a0hpQxylbbIw5Q260pEwh6JgRlUAXcyJ zYe+13xjNbX5MR6pKmyI06I/MTBL8HfpVs00sgkZSFFPVp+8qI33/CGeJuReU6k3gAJN D4ZtVJacdbgx6hUVOOcb4fBkpid3z7oG3sCQcR7CPkuMeY3FumCd0DIHgDLlcHghzwLZ dC/ys9J/P8DuWhAW4xBOSBGTPyP3E0IXd4v0zIx9mluFl6hxFCXakZp4pDI8CmYCin3k WsdA== X-Gm-Message-State: ALyK8tJt+qHdA0N79ED2Td/0gLIsnSylgyd2Sdmad0X/br36kKfxEdpZbH8w1wPUU5RsyMbAiMFctGvWPS4oSA== X-Received: by 10.202.225.212 with SMTP id y203mr9248238oig.47.1468249502511; Mon, 11 Jul 2016 08:05:02 -0700 (PDT) In-Reply-To: <7fcc8c21-106f-41d4-a5ba-409f3b54a56d@googlegroups.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: X-Mailman-Original-References: <834b1cce-38dd-474c-8915-4ff1cd6b27ec@googlegroups.com> <7fcc8c21-106f-41d4-a5ba-409f3b54a56d@googlegroups.com> Xref: csiph.com comp.lang.python:111272 On Sun, Jul 10, 2016 at 6:34 PM, Lawrence D=E2=80=99Oliveiro wrote: > On Sunday, July 10, 2016 at 7:22:42 PM UTC+12, Ian wrote: >> On Sat, Jul 9, 2016 at 11:54 PM, Lawrence D=E2=80=99Oliveiro wrote: >>> In printf-style formats, you can specify the number of digits for an >>> integer separately from the field width. E.g. >>> >>> >>> "%#0.5x" % 0x123 >>> '0x00123' >>> >> except perhaps that precision doesn't really make sense for integers >> in the first place. > > Except that it does make sense, as I showed in my example. Your example showed a 3-digit number being formatted with a requested precision of 5 digits. The way this was done was by left-padding the number with 0s until there were 5 digits, but still only 3 digits of precision. If you truly wanted to format the number with a precision of 5 digits, it would look like this: 0x123.00 It may happen to do what you want in the printf-style format, but calling the field "precision" is at best misleading, and there are other ways to accomplish the same result. > Well, str.format does not use the same syntax as printf.