Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #31294
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <chris@rebertia.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.003 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'e.g.,': 0.07; 'subject:question': 0.08; 'django,': 0.09; 'received:mail- vb0-f46.google.com': 0.09; 'subject:string': 0.09; 'cc:addr :python-list': 0.10; 'template': 0.11; '2.00': 0.16; 'oct': 0.16; 'subject:simple': 0.16; 'url:djangoproject': 0.16; 'mon,': 0.16; 'wrote:': 0.17; 'specify': 0.17; 'url:dev': 0.17; 'received:209.85.212.46': 0.18; 'written': 0.20; 'cheers,': 0.23; 'cc:2**0': 0.23; '15,': 0.23; 'seems': 0.23; 'cc:no real name:2**0': 0.24; 'tried': 0.25; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'am,': 0.27; 'message- id:@mail.gmail.com': 0.27; 'received:209.85.212': 0.28; 'chris': 0.28; 'no,': 0.29; 'point': 0.31; 'implement': 0.32; 'received:google.com': 0.34; 'project': 0.34; 'received:209.85': 0.35; 'there': 0.35; 'but': 0.36; 'uses': 0.37; 'received:209': 0.37; 'subject:: ': 0.38; 'url:docs': 0.38; 'url:en': 0.38; 'header:Received:5': 0.40; 'your': 0.60; "you'll": 0.62; 'more': 0.63; 'find.': 0.84; 'sender:addr:chris': 0.84; 'url:templates': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=ne2bMfQAzesVzYYaObcsLNtBmNvdFiceBCc9vVGtZxA=; b=b86xLucnmbiT5tn2baHoZQaogKSwKqTVtcBXIRadJ4vN54JMB0++5JOMcEK9xHoQyk cQVahvS8xQk88LWxaiA0EQKhTjezA8NWfa5biKyA6myo4yo5b/lSuHys/+rZ0K9qlSuN +pyWY0DA1iROc47Nufdx7k5g3Jpw1V6crXe4U= |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :x-gm-message-state; bh=ne2bMfQAzesVzYYaObcsLNtBmNvdFiceBCc9vVGtZxA=; b=jcOxLfj1c873Erm0lz1K4yCi3d+Ayi6rlBhDsZ88+QOHCZohRlc40WDg9OKhECzX+8 gRhPD34LJ8U0Fn7pX6HIKQGwId5c2pRsAdRduql2YvUQZJ5L95tKAgbRsjGL4WsGT1g0 erI6Q/EKrLBfANOcv+K28G1jH0hWdB29kRdCCIObSSD/jq0yhHC2RnyAaOcx2S7E39Vz 6IpAuEI8zSPsmRQHgzVS04thK+rds0X4LX0RCjL2vKumvCBCgIkekH45t5KOnJuPlkob aG/1slw8TnM1xv+nXmulVbu6oxU7irsrWtL3ITTbdLyFJbVmJmCXFc5kg0whfmyTNToo refQ== |
| MIME-Version | 1.0 |
| Sender | chris@rebertia.com |
| In-Reply-To | <k5guje$ui$1@ger.gmane.org> |
| References | <k5guje$ui$1@ger.gmane.org> |
| Date | Mon, 15 Oct 2012 05:29:59 -0700 |
| X-Google-Sender-Auth | WVzmBm7zLbCpE48FuTwoPF_jScE |
| Subject | Re: simple string format question |
| From | Chris Rebert <clp2@rebertia.com> |
| To | Neal Becker <ndbecker2@gmail.com> |
| Content-Type | text/plain; charset=UTF-8 |
| X-Gm-Message-State | ALoCoQlo1P4QWn8ypBhmStiJqzsJ55FVWRumR0GzCkKJFdYsmqHp5JvgV7vT9wVszSXeOlqGTwnS |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://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 | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2198.1350304201.27098.python-list@python.org> (permalink) |
| Lines | 17 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1350304201 news.xs4all.nl 6889 [2001:888:2000:d::a6]:47583 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:31294 |
Show key headers only | View raw
On Mon, Oct 15, 2012 at 5:12 AM, Neal Becker <ndbecker2@gmail.com> wrote:
> Is there a way to specify to format I want a floating point written with no more
> than e.g., 2 digits after the decimal? I tried {:.2f}, but then I get all
> floats written with 2 digits, even if they are 0:
>
> 2.35 << yes, that's what I want
> 2.00 << no, I want just 2 or 2.
Not that I can find. Seems you'll have to implement it yourself.
In the event that your project uses Django, there happens to be a
template tag for this (pass it -2 in your case):
https://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#floatformat
Cheers,
Chris
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: simple string format question Chris Rebert <clp2@rebertia.com> - 2012-10-15 05:29 -0700
csiph-web