Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #111283

Re: Curious Omission In New-Style Formats

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Ian Kelly <ian.g.kelly@gmail.com>
Newsgroups comp.lang.python
Subject Re: Curious Omission In New-Style Formats
Date Mon, 11 Jul 2016 12:38:36 -0600
Lines 49
Message-ID <mailman.185.1468262372.2295.python-list@python.org> (permalink)
References <834b1cce-38dd-474c-8915-4ff1cd6b27ec@googlegroups.com> <CALwzidmwcc0nTLtLBJm=JNAjOQNRe2umtmNXNAk=s+xoyxhU6Q@mail.gmail.com> <mailman.161.1468135349.2295.python-list@python.org> <7fcc8c21-106f-41d4-a5ba-409f3b54a56d@googlegroups.com> <CALwzidkiRh2+ttXewaQzyJhAKMjTb7AXYk=E2SxGyH_jw9o1gw@mail.gmail.com> <mailman.180.1468249505.2295.python-list@python.org> <5783c91e$0$1622$c3e8da3$5496439d@news.astraweb.com> <CALwzid=r90j900FMJDN7YLbowmauB4SDifoHZFimPa2DvqMZ6Q@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de 4SwGBmgpuTD6MAMK7AVRDA7mblcSqHsyTcIZ5JtEzU6Q==
Return-Path <ian.g.kelly@gmail.com>
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; 'float': 0.05; '(of': 0.07; 'formatting': 0.07; 'formatted': 0.09; 'output,': 0.09; 'output': 0.13; 'result.': 0.15; '2016': 0.16; 'digits.': 0.16; 'guess.': 0.16; 'hexadecimal': 0.16; 'integer.': 0.16; 'number?': 0.16; 'precision.': 0.16; 'printf': 0.16; 'printf-style': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'zeroes': 0.16; 'wrote:': 0.16; 'assuming': 0.22; 'precise': 0.22; 'am,': 0.23; 'represents': 0.23; 'this:': 0.23; 'written': 0.24; 'header:In- Reply-To:1': 0.24; 'mon,': 0.24; "i've": 0.25; 'example': 0.26; 'right.': 0.27; 'message-id:@mail.gmail.com': 0.27; 'format,': 0.27; 'decimal': 0.29; 'convert': 0.29; "d'aprano": 0.33; 'point,': 0.33; 'steven': 0.33; 'tue,': 0.34; 'add': 0.34; 'received:google.com': 0.35; 'could': 0.35; 'done': 0.35; 'but': 0.36; 'should': 0.36; 'there': 0.36; 'winning': 0.36; 'to:addr :python-list': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'being': 0.37; 'say': 0.37; 'wanted': 0.37; 'seem': 0.37; 'no,': 0.38; 'why': 0.39; 'format': 0.39; 'does': 0.39; 'subject:-': 0.39; 'to:addr:python.org': 0.40; 'still': 0.40; 'field': 0.60; 'your': 0.60; 'claim': 0.61; 'decision': 0.61; 'leading': 0.61; 'more': 0.63; 'quantity': 0.66; 'jul': 0.72; 'naturally.': 0.84; 'to:name:python': 0.84
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:to; bh=5G1DbPQc+4N+bWDCo0+AR51UDpIWygfSL+kdCFDUutg=; b=VjMmdbvYBwYwS0/kH6cimJOUDOxWL6yAP5IVNJAg2XYeFGcwfjnJhBvkPs7GW36MEL 1+ofpMWV78FvPWi/lTUJj+tur+lLCeRAjm72CJT5YfxAXnYcHjBGSogJa6u27n3qtHJY GT9N5hADkWFUgSJtXYTJj+/jAz70xloxq5bm6oWoprm2abrFnoBM6tBARGHKyVZH2dNu Eim6Y92imv51L5S24+wTVlUGQHLK/jyjZry/Npmj5ItVuxDpBJb9agptB78Pe5fRO2NN GMZ1NZQDDH3X9D1fAlstRLu22isbZ09jbRo7Dev7vyp5Oi7n0uCOpR/sB2Ii6FRpL5WC ylXA==
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:to; bh=5G1DbPQc+4N+bWDCo0+AR51UDpIWygfSL+kdCFDUutg=; b=JzEX/yFxODLNZzotC4nAyk3OrFmf34IsECm+iCd0L84XXluyh6n13sBTEP4uhHALPz HPZBAMF2YJcw2EaVdNPlIbIgWEUFWBi5eAvsF+f2p/Z8khiAG1V7H689A7tO8s8zW7OU 9tdKNbBaYGI1pzmZYxuqSCyh1Ak4UMyjPMeYAE+RYJwV0d0Zzv66XwB2r1cTk+40ZlPa JbhdN+/X0cVUChRYtWP+w2xZIXc3OlDZ7ur0X45HYd7gf2qD4WwElZ1muv83wW2HGAhV RfV2gnAKvxwfQpfiVfV0AUZr3PjQzvp9CrD4PA5rZPlMnW6CpYeEndQdb5ZBEHlaAskq NbGw==
X-Gm-Message-State ALyK8tI3NLeizcq6McovqtvdM4qor3JnZXoudrusQQiIV6EtG0PyrlP6pt1ebBjqVv5lE6NTS4EYgADVzXNKMA==
X-Received by 10.202.92.138 with SMTP id q132mr9793677oib.54.1468262355677; Mon, 11 Jul 2016 11:39:15 -0700 (PDT)
In-Reply-To <5783c91e$0$1622$c3e8da3$5496439d@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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <CALwzid=r90j900FMJDN7YLbowmauB4SDifoHZFimPa2DvqMZ6Q@mail.gmail.com>
X-Mailman-Original-References <834b1cce-38dd-474c-8915-4ff1cd6b27ec@googlegroups.com> <CALwzidmwcc0nTLtLBJm=JNAjOQNRe2umtmNXNAk=s+xoyxhU6Q@mail.gmail.com> <mailman.161.1468135349.2295.python-list@python.org> <7fcc8c21-106f-41d4-a5ba-409f3b54a56d@googlegroups.com> <CALwzidkiRh2+ttXewaQzyJhAKMjTb7AXYk=E2SxGyH_jw9o1gw@mail.gmail.com> <mailman.180.1468249505.2295.python-list@python.org> <5783c91e$0$1622$c3e8da3$5496439d@news.astraweb.com>
Xref csiph.com comp.lang.python:111283

Show key headers only | View raw


On Mon, Jul 11, 2016 at 10:28 AM, Steven D'Aprano <steve@pearwood.info> wrote:
> On Tue, 12 Jul 2016 01:04 am, Ian Kelly wrote:
>> 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,
>
> Right.
>
>> but still only 3 digits of precision.
>
> 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. That might be the way
> printf interprets the precision for *floats*, but its not the way it
> interprets the precision for *ints*, and who is to say that one way is
> right and the other is wrong?

In what way do the leading zeroes in "00123" add to the precision of
the number? 00123 is the same quantity as 123 and represents no more
precise a measurement. Neither does 0000000123 for "ten" digits of
precision. We could just keep adding zeroes ad nauseam and then claim
that 123 has infinite precision.

Clearly, that's wrong.

>> If you truly wanted to format the number with a precision
>> of 5 digits, it would look like this:
>>
>>     0x123.00
>
> Er, no, because its an integer.

Which is why if you actually want to do this, you should convert it to
a decimal or a float first (of course, those don't support hexadecimal
output, so if you actually want hexadecimal output *and* digits after
the (hexa)decimal point, then I think you would just have to roll your
own formatting at that point).

>> 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.
>
> Naturally. So why bother to have .format() or % in the first place? There's
> always other ways to accomplish the same result.

I think it's just a case of purity winning out over practicality. As I
said before, I don't really know why the decision was made to not
support or allow it. What I've written above was my best guess.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Curious Omission In New-Style Formats Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-09 22:54 -0700
  Re: Curious Omission In New-Style Formats Ian Kelly <ian.g.kelly@gmail.com> - 2016-07-10 01:21 -0600
    Re: Curious Omission In New-Style Formats Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-10 17:34 -0700
      Re: Curious Omission In New-Style Formats Ian Kelly <ian.g.kelly@gmail.com> - 2016-07-11 09:04 -0600
        Re: Curious Omission In New-Style Formats Steven D'Aprano <steve@pearwood.info> - 2016-07-12 02:28 +1000
          Re: Curious Omission In New-Style Formats Ethan Furman <ethan@stoneleaf.us> - 2016-07-11 10:24 -0700
            Re: Curious Omission In New-Style Formats Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-07-12 11:47 +1200
              Re: Curious Omission In New-Style Formats Ethan Furman <ethan@stoneleaf.us> - 2016-07-11 17:24 -0700
              Re: Curious Omission In New-Style Formats Ian Kelly <ian.g.kelly@gmail.com> - 2016-07-11 19:16 -0600
          Re: Curious Omission In New-Style Formats Ian Kelly <ian.g.kelly@gmail.com> - 2016-07-11 12:38 -0600
            Re: Curious Omission In New-Style Formats Steven D'Aprano <steve@pearwood.info> - 2016-07-12 13:38 +1000
              Re: Curious Omission In New-Style Formats Ian Kelly <ian.g.kelly@gmail.com> - 2016-07-13 00:21 -0600
                Re: Curious Omission In New-Style Formats Marko Rauhamaa <marko@pacujo.net> - 2016-07-13 09:57 +0300
                Re: Curious Omission In New-Style Formats Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-13 00:05 -0700
                Re: Curious Omission In New-Style Formats Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-07-13 18:49 +1000
                Re: Curious Omission In New-Style Formats Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2016-07-13 16:01 +0200
                Re: Curious Omission In New-Style Formats Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-07-13 20:04 -0400
                Re: Curious Omission In New-Style Formats Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-13 15:24 -0700
                Re: Curious Omission In New-Style Formats Ian Kelly <ian.g.kelly@gmail.com> - 2016-07-13 18:45 -0600
                Re: Curious Omission In New-Style Formats Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-13 20:39 -0700
                Re: Curious Omission In New-Style Formats Ian Kelly <ian.g.kelly@gmail.com> - 2016-07-13 23:18 -0600
                Re: Curious Omission In New-Style Formats Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-07-14 17:47 +1000
                Re: Curious Omission In New-Style Formats Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-07-14 07:34 -0400
                Re: Curious Omission In New-Style Formats Ian Kelly <ian.g.kelly@gmail.com> - 2016-07-14 08:30 -0600
                Re: Curious Omission In New-Style Formats Marko Rauhamaa <marko@pacujo.net> - 2016-07-14 19:02 +0300
                Re: Curious Omission In New-Style Formats Ian Kelly <ian.g.kelly@gmail.com> - 2016-07-14 11:10 -0600
                Re: Curious Omission In New-Style Formats Marko Rauhamaa <marko@pacujo.net> - 2016-07-14 20:30 +0300
                Re: Curious Omission In New-Style Formats Ian Kelly <ian.g.kelly@gmail.com> - 2016-07-14 18:17 -0600
                Re: Curious Omission In New-Style Formats Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-14 18:08 -0700
                Re: Curious Omission In New-Style Formats Marko Rauhamaa <marko@pacujo.net> - 2016-07-15 09:06 +0300
                Re: Curious Omission In New-Style Formats Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2016-07-15 09:54 +0200
                Re: Curious Omission In New-Style Formats Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-07-15 11:40 +0300
                Re: Curious Omission In New-Style Formats Steven D'Aprano <steve@pearwood.info> - 2016-07-15 20:56 +1000
                Re: Curious Omission In New-Style Formats Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2016-07-15 13:44 +0200
                Re: Curious Omission In New-Style Formats Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-07-15 16:38 +0300
                Re: Curious Omission In New-Style Formats Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2016-07-15 16:47 +0200
                Re: Curious Omission In New-Style Formats Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-07-15 16:13 +0300
                Re: Curious Omission In New-Style Formats Steven D'Aprano <steve@pearwood.info> - 2016-07-16 01:12 +1000
                Re: Curious Omission In New-Style Formats Random832 <random832@fastmail.com> - 2016-07-15 09:39 -0400
                Re: Curious Omission In New-Style Formats Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2016-07-15 16:32 +0200
                Re: Curious Omission In New-Style Formats Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2016-07-15 13:05 +0200
                Re: Curious Omission In New-Style Formats Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-07-15 16:28 +0300
                Re: Curious Omission In New-Style Formats Steven D'Aprano <steve@pearwood.info> - 2016-07-16 01:13 +1000
                Re: Curious Omission In New-Style Formats Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-07-15 18:27 +0300
                Re: Curious Omission In New-Style Formats Marko Rauhamaa <marko@pacujo.net> - 2016-07-15 12:20 +0300
                Re: Curious Omission In New-Style Formats Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2016-07-15 12:44 +0200
                Re: Curious Omission In New-Style Formats Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-14 16:26 -0700
                Re: Curious Omission In New-Style Formats Robert Kern <robert.kern@gmail.com> - 2016-07-14 16:17 +0100
                Re: Curious Omission In New-Style Formats Lawrence D’Oliveiro <lawrencedo99@gmail.com> - 2016-07-15 16:35 -0700
                Re: Curious Omission In New-Style Formats Chris Angelico <rosuav@gmail.com> - 2016-07-16 10:57 +1000
                Re: Curious Omission In New-Style Formats MRAB <python@mrabarnett.plus.com> - 2016-07-14 01:59 +0100
              Re: Curious Omission In New-Style Formats Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2016-07-13 07:46 -0400
                Re: Curious Omission In New-Style Formats Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-07-13 16:04 +0300
              Re: Curious Omission In New-Style Formats Chris Angelico <rosuav@gmail.com> - 2016-07-13 23:00 +1000
                Re: Curious Omission In New-Style Formats Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-07-13 16:16 +0300
                Re: Curious Omission In New-Style Formats Chris Angelico <rosuav@gmail.com> - 2016-07-13 23:49 +1000
                Re: Curious Omission In New-Style Formats Jussi Piitulainen <jussi.piitulainen@helsinki.fi> - 2016-07-13 17:23 +0300
                Re: Curious Omission In New-Style Formats Chris Angelico <rosuav@gmail.com> - 2016-07-14 00:28 +1000
          Re: Curious Omission In New-Style Formats Terry Reedy <tjreedy@udel.edu> - 2016-07-11 14:54 -0400
          Re: Curious Omission In New-Style Formats Ian Kelly <ian.g.kelly@gmail.com> - 2016-07-11 13:27 -0600
          Re: Curious Omission In New-Style Formats Michael Torrie <torriem@gmail.com> - 2016-07-11 14:06 -0600
          Re: Curious Omission In New-Style Formats Random832 <random832@fastmail.com> - 2016-07-11 16:34 -0400
          Re: Curious Omission In New-Style Formats Terry Reedy <tjreedy@udel.edu> - 2016-07-11 16:52 -0400
          What is precision of a number representation? (was: Curious Omission In New-Style Formats) Ben Finney <ben+python@benfinney.id.au> - 2016-07-12 06:56 +1000
            Re: What is precision of a number representation? Ben Bacarisse <ben.usenet@bsb.me.uk> - 2016-07-11 23:28 +0100
          Re: What is precision of a number representation? Ethan Furman <ethan@stoneleaf.us> - 2016-07-11 14:22 -0700
          Re: What is precision of a number representation? (was: Curious Omission In New-Style Formats) Chris Angelico <rosuav@gmail.com> - 2016-07-12 07:51 +1000
            Re: What is precision of a number representation? (was: Curious Omission In New-Style Formats) Jan Coombs <jenfhaomndgfwutc@murmic.plus.com> - 2016-07-12 00:14 +0100
              Re: What is precision of a number representation? (was: Curious Omission In New-Style Formats) Chris Angelico <rosuav@gmail.com> - 2016-07-12 09:57 +1000
            Re: What is precision of a number representation? (was: Curious Omission In New-Style Formats) Steven D'Aprano <steve@pearwood.info> - 2016-07-12 14:19 +1000
              Re: What is precision of a number representation? (was: Curious Omission In New-Style Formats) Chris Angelico <rosuav@gmail.com> - 2016-07-12 14:36 +1000
              Re: What is precision of a number representation? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2016-07-12 11:50 +0200
                Re: What is precision of a number representation? Marko Rauhamaa <marko@pacujo.net> - 2016-07-12 13:27 +0300
                Re: What is precision of a number representation? Antoon Pardon <antoon.pardon@rece.vub.ac.be> - 2016-07-12 13:02 +0200
                Re: What is precision of a number representation? Steven D'Aprano <steve@pearwood.info> - 2016-07-12 23:16 +1000
          Re: What is precision of a number representation? Ethan Furman <ethan@stoneleaf.us> - 2016-07-11 15:17 -0700
            Re: What is precision of a number representation? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2016-07-12 16:21 +1000
              Re: What is precision of a number representation? Random832 <random832@fastmail.com> - 2016-07-12 09:36 -0400
          Re: What is precision of a number representation? Ethan Furman <ethan@stoneleaf.us> - 2016-07-11 15:29 -0700
          Re: Curious Omission In New-Style Formats Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-07-12 11:26 +1200
          Re: What is precision of a number representation? Chris Angelico <rosuav@gmail.com> - 2016-07-12 11:57 +1000
          Re: What is precision of a number representation? Ben Finney <ben+python@benfinney.id.au> - 2016-07-12 13:41 +1000
          Re: What is precision of a number representation? Terry Reedy <tjreedy@udel.edu> - 2016-07-12 00:14 -0400
          Re: What is precision of a number representation? Terry Reedy <tjreedy@udel.edu> - 2016-07-12 00:17 -0400

csiph-web