Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.024 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'string': 0.09; 'formatting': 0.09; 'trailing': 0.09; '(default': 0.16; '9.9': 0.16; 'exponential': 0.16; 'notation': 0.16; 'specifier': 0.16; 'switches': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'feb': 0.22; '>>>': 0.22; '15,': 0.26; 'gets': 0.27; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'scale': 0.29; '(like': 0.30; 'specified': 0.30; 'message-id:@mail.gmail.com': 0.30; "skip:' 10": 0.31; 'subject:numbers': 0.31; 'url:python': 0.33; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'possible': 0.36; 'url:org': 0.36; 'behind': 0.37; 'url:library': 0.38; 'to:addr :python-list': 0.38; 'to:addr:python.org': 0.39; 'remove': 0.60; 'read': 0.60; 'url:3': 0.61; 'more': 0.64; 'hey,': 0.75; 'details:': 0.80 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 :content-type; bh=ezWDvpfNawVpVCRS58RC98UTKVS2zlk2J+tiW8BCQ3A=; b=TBKRNA8BHZHKutx5+ooEJMD2kpTmBdRk0aYpydHXm+94KCwBYz/XllXq08JibcByfC AFAKjPSv1wKMYFJzRUanloRpKOcxTOnKKuxZCa1cBBYry2Svtu3GIRQKk66HfXyExG/5 /opaU3J3PQWykILPEAYtlR9mR92jjI4DVNoe2SCZcDWvZqh3aH4IqJW3fO8zTIbffZdQ 0BX9WKDtpFMkUSop9L9HxGHxq17+BNeq9iA58AAA5p1oWwjh2HJxM+zHUADqxicLzqvE RwZ88/pDEy8c80rYwZ0vsxi63auuXALblspWWg8UZIXTRvFA1wnCyNFUjuPagTpuGFEH hlAA== X-Received: by 10.68.230.137 with SMTP id sy9mr17173872pbc.126.1392500125723; Sat, 15 Feb 2014 13:35:25 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <877d1ddd-39d8-4ede-8dff-addade1c57cd@googlegroups.com> References: <833583c7-c307-4ebf-9a60-3be146a565b5@googlegroups.com> <9c1b03cb-c607-4784-aaec-78616988c302@googlegroups.com> <877d1ddd-39d8-4ede-8dff-addade1c57cd@googlegroups.com> From: Ian Kelly Date: Sat, 15 Feb 2014 14:34:45 -0700 Subject: Re: decimal numbers To: Python Content-Type: text/plain; charset=ISO-8859-1 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: 16 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1392500128 news.xs4all.nl 2896 [2001:888:2000:d::a6]:54645 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:66485 On Sat, Feb 15, 2014 at 11:57 AM, Luke Geelen wrote: > hey, is it possible to remove the .0 if it is a valua without something behind the poit (like 5.0 gets 5 but 9.9 stays 9.9 The ':g' format specifier will trim off trailing zeroes, e.g.: >>> '{:g}'.format(5.0) '5' It also switches to exponential notation if the scale of the number is greater than the specified precision (default 6): >>> '{:g}'.format(5000000.0) '5e+06' You can read up on string formatting for more details: http://docs.python.org/3/library/string.html#formatstrings