Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'e.g.,': 0.07; 'subject:question': 0.08; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:string': 0.09; '2.00': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:simple': 0.16; 'specify': 0.17; 'written': 0.20; 'tried': 0.25; 'header:User-Agent:1': 0.26; 'header:X-Complaints-To:1': 0.28; 'no,': 0.29; 'point': 0.31; 'to:addr:python-list': 0.33; 'there': 0.35; 'received:org': 0.36; 'but': 0.36; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'more': 0.63; 'received:139': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Neal Becker Subject: simple string format question Date: Mon, 15 Oct 2012 08:12:31 -0400 Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Gmane-NNTP-Posting-Host: 139.85.237.139 User-Agent: KNode/4.9.2 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 7 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1350303164 news.xs4all.nl 6863 [2001:888:2000:d::a6]:41562 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:31293 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.