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


Groups > comp.lang.python > #102103

Re: .format won't display my value with 2 decimal places: Why?

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Chris Kaynor <ckaynor@zindagigames.com>
Newsgroups comp.lang.python
Subject Re: .format won't display my value with 2 decimal places: Why?
Date Mon, 25 Jan 2016 12:40:32 -0800
Lines 35
Message-ID <mailman.0.1453754460.2338.python-list@python.org> (permalink)
References <56A1B69F.3040300@gmail.com> <em59031268-5aa7-4141-b0ba-f5de9a9f9261@andromeda> <CALwzidmWXJdFq1DbW3_zTGVeDbxW0W2BeLcyc20PXCAiGFr-1A@mail.gmail.com> <CAPTjJmoFitkYrv6A2-MZCsJ1EiXjmi9w4mCTqHH8s4MZPHi3jQ@mail.gmail.com> <1453743169.404634.502055130.69AAD060@webmail.messagingengine.com> <CAPTjJmqCB-=wtb7xHvmxCX0R7wWOSCRKtESDqs6WrfFBFSWnqg@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8
X-Trace news.uni-berlin.de GhbvMCEFjATw6uif0z1B1A1vYpZSXUZsuCtgSNc8MutQ==
Return-Path <ckaynor@zindagigames.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'string.': 0.04; 'formatting': 0.07; 'none)': 0.07; 'differently.': 0.09; 'parameter.': 0.09; 'subject:Why': 0.09; 'translations': 0.09; 'translator': 0.09; 'jan': 0.11; 'template': 0.11; 'times,': 0.13; 'ignore': 0.14; 'languages,': 0.15; '2016': 0.16; 'included,': 0.16; 'multiple,': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'singular': 0.16; 'templating': 0.16; 'variations': 0.16; 'wrote:': 0.16; 'translation': 0.16; 'string': 0.17; 'flexibility': 0.18; '&gt;': 0.18; 'email addr:gmail.com&gt;': 0.18; 'all,': 0.20; 'to:name:python-list@python.org': 0.20; 'saying': 0.22; 'arguments': 0.22; 'am,': 0.23; 'code.': 0.23; 'decide': 0.23; 'header:In-Reply-To:1': 0.24; 'mon,': 0.24; 'sense': 0.26; 'chris': 0.26; 'message-id:@mail.gmail.com': 0.27; 'data,': 0.27; 'cases.': 0.29; 'does,': 0.29; 'strings,': 0.29; 'subset': 0.29; "i'm": 0.30; 'system,': 0.30; 'fixed': 0.31; 'maybe': 0.33; 'run': 0.33; 'useful': 0.33; 'case,': 0.34; 'tue,': 0.34; 'received:google.com': 0.35; 'designer': 0.35; 'sometimes': 0.35; 'but': 0.36; 'project': 0.36; 'lines': 0.36; 'received:209.85': 0.36; 'possible': 0.36; '(and': 0.36; 'cases': 0.36; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'being': 0.37; 'received:209.85.213': 0.37; 'received:209': 0.38; 'mean': 0.38; 'data': 0.39; 'sure': 0.39; 'rather': 0.39; 'build': 0.40; 'to:addr:python.org': 0.40; 'where': 0.40; 'subject:with': 0.40; 'still': 0.40; 'some': 0.40; 'different': 0.63; 'quantity': 0.66; 'situation': 0.67; 'choose': 0.68; '26,': 0.72; 'special': 0.73; '(is': 0.84; 'subject:value': 0.84; 'carries': 0.91; 'spell': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=zindagigames-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=SjSBVML6u07nmYYWX7ESjq8n42KyYz56bl9rwBlKamA=; b=xlyU+zh0b0Nkbj/SmPjcT9R2boOmCdc/kTEiECrH8jgYTKxZq+uq9keahxH2D5exfh +XdpJWgNaDDWxdKLtzf/GY76b8Q4tsjrHHMjzvfbz5CelT3hTHT3ossWNBOUOCE1WRwO QrAlFACBmsPkzFIkPddfQiIkqLX0+QIxYzVBWROy15Dq6sKhW8UCmtin9EwoFIC7JYsV Y2lAdmoQuW5aDSlLBRr9pQQPIpf7ljMv3HeSSROYZGkCydpOxeqaL/yj6kwdM4ib/bwM jSsSfRWJvYFZpQ398qERAJpPqt+boI6h2JL2ygEj7CuGXCNsMAvApH4eZHUEiKES/27C ZOUQ==
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:content-type; bh=SjSBVML6u07nmYYWX7ESjq8n42KyYz56bl9rwBlKamA=; b=f+FU5bTwN1u9hftsPP2JMHl7NyaADyFO8YhSiKhHDzDUsGntOWfXGuekmz/jpSUOkT UGqeV4euMMRHQyyf/QT6lY+2Cbtesl5dNoyRtLaZAfC4Z7nyE1fDwLy6G3ano5HqGOvw 0gdCakE8ZhmYQhdNGVWDbmUCpgj5zKyOIDQEPO2vPgDZ6IPRVaUhl3o8aOKJneug7oyI rnuH00/7gy6Q8XGGX3GcbWTSA0FbKZ07ML6Ogp1TjorjBKvq2BNY8ZNMr0DmJSLbbcr1 8zd3EXyPS2VaFSuJvheidYHtxvI2U6AcW3JvIlLUiuKQ7+kGS8FXWaqDWQ61zXrfD17l BMeg==
X-Gm-Message-State AG10YOS8DBh8p+00KaRQ1tf/V1MzMkO6Whavz++7hrWFNX50jYJTZGHzfqTQdt8nKDmqlGG2hBR01c5/sVgr3A==
X-Received by 10.31.167.195 with SMTP id q186mr11482699vke.113.1453754452295; Mon, 25 Jan 2016 12:40:52 -0800 (PST)
In-Reply-To <CAPTjJmqCB-=wtb7xHvmxCX0R7wWOSCRKtESDqs6WrfFBFSWnqg@mail.gmail.com>
X-Content-Filtered-By Mailman/MimeDel 2.1.20+
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
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>
Xref csiph.com comp.lang.python:102103

Show key headers only | View raw


On Mon, Jan 25, 2016 at 9:48 AM, Chris Angelico <rosuav@gmail.com> wrote:

> On Tue, Jan 26, 2016 at 4:32 AM, Random832 <random832@fastmail.com> wrote:
> > On Mon, Jan 25, 2016, at 12:23, Chris Angelico wrote:
> >> if some translations don't use a token at all,
> >
> > I'm not sure what situation that would be reasonable in.
>
> I don't do much with different human languages, but it's possible that
> you might build up a message in a variety of different ways, and
> include tokens differently. Maybe you'd include a product name in two
> different places, and each translation would get to choose which of
> the lines includes it. Maybe there's a fixed string that carries the
> sense of what you're saying better than the parameterized one does, so
> you ignore the parameter. It's the same flexibility as reordering
> tokens, but some tokens get reordered to nowhere. (Is it still a
> teleportation spell when the destination is oblivion? -- Venser)


One of the most useful reasons to not require all arguments be used is when
using the string as part of a templating system, though in those cases,
using named (over positional) arguments makes it easiest.

While I have not seen any cases where some arguments go unused in other
languages, it is often useful to generate a bunch of data, and let a
designer or translator decide on the exact arguments to use in a specific
string. Often times, this will mean using different template strings, which
only use a subset (and sometimes even none) of the arguments.

While not using Python, a project I am working on uses this for some of the
data being displayed. In this case, some of the template strings do not use
any template values, while others use multiple, but rather than have to
special case each variation, it can just run the template strings though
formatting code. This is particularly useful in the cases where a quantity
is included, and variations are used for singular vs plural cases.

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


Thread

Re: .format won't display my value with 2 decimal places: Why? Chris Kaynor <ckaynor@zindagigames.com> - 2016-01-25 12:40 -0800

csiph-web