Deutsch English Français Italiano |
<mailman.3.1724637492.2917.python-list@python.org> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!weretis.net!feeder8.news.weretis.net!fu-berlin.de!uni-berlin.de!not-for-mail From: MRAB <python@mrabarnett.plus.com> Newsgroups: comp.lang.python Subject: Re: Is there a better way? [combining f-string, thousands separator, right align] Date: Mon, 26 Aug 2024 02:55:03 +0100 Lines: 20 Message-ID: <mailman.3.1724637492.2917.python-list@python.org> References: <oRHyO.142039$bV6e.134076@fx08.ams4> <85ea3168-cd47-4f06-97f8-5f98ee21c8b9@mrabarnett.plus.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 00gIRkO2WttKrZEyzynsVw2fWm8DjfWO3uW0m9AAX5vg== Cancel-Lock: sha1:DMI2PNSs+tHtNKCaLYahFkoI2Kc= sha256:4HpM91BIA3Uvh6tiBj/jgzjTny2KVclFiiRrwwC83gw= Return-Path: <python@mrabarnett.plus.com> X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org Authentication-Results: mail.python.org; dkim=pass reason="2048-bit key; unprotected key" header.d=plus.com header.i=@plus.com header.b=lvJ+oNUs; dkim-adsp=none (unprotected policy); dkim-atps=neutral X-Spam-Status: OK 0.014 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'from:addr:python': 0.09; 'received:192.168.1.64': 0.09; 'subject:, \n ': 0.09; '>>>>': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'received:plus.net': 0.16; 'subject:align': 0.16; 'subject:string': 0.16; 'subject:way': 0.16; 'wrote:': 0.16; 'to:addr:python-list': 0.20; '>>>': 0.28; 'it,': 0.29; 'header :User-Agent:1': 0.30; 'default': 0.31; 'python-list': 0.32; 'subject:there': 0.32; 'received:192.168.1': 0.32; 'header:In- Reply-To:1': 0.34; 'received:192.168': 0.37; 'format': 0.62; 'received:212': 0.62; 'subject': 0.63; 'subject:]': 0.70; 'subject:better': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=plus.com; s=042019; t=1724637304; bh=Qs5M6sX+Irh9p59bFnGgDLrWVxawPM2pXhpdfo7e3KQ=; h=Date:Subject:To:References:From:In-Reply-To; b=lvJ+oNUso0NtB0MXhOirZOA66bexqLmk8Jvyfbd7iiNvt9Mi/tPObqL3zKz6h9p0l s1murCLb3qRQZbBnt283WC24kDXw/RL4L1/UhA8wbO2VWwjVncIxBG02uWYMv7umhT +d6zA06yPD9q8KCsQGtTV1jcvK1iUuwXs7en4SmTBC1t6cPgIotQHCY5c7lbpnKRqF 5MhhSdGgmgAyRPFY82omJip6NHFMBRcIRue1MKZsV+aHYxyGSpRB1Ar1e9cfEOG9o7 2Iu9rivthdm+xkWpqMZarEpudTwpKDbuth34g1gZruanpRnVS1U/aBAP/Ffyc4LG54 dpmi4scRh4tfw== X-Clacks-Overhead: "GNU Terry Pratchett" X-CM-Score: 0.00 X-CNFS-Analysis: v=2.4 cv=VaJUP0p9 c=1 sm=1 tr=0 ts=66cbe078 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=MV0liI4DTSMKKfbT:21 a=IkcTkHD0fZMA:10 a=7YnVGVZCoM_dpXUQtdsA:9 a=QEXdDO2ut3YA:10 X-AUTH: mrabarnett@:2500 User-Agent: Mozilla Thunderbird Content-Language: en-GB In-Reply-To: <oRHyO.142039$bV6e.134076@fx08.ams4> X-CMAE-Envelope: MS4xfBmfVg0KKEOJ4S1d8oyyGU/QHkUR/gAwiOdgyN1i492MBvTF1f+hrj29YOMKaXC1kINaf8OMx4f1H/OuBI0rKHkcjkx8kJw6A7f0egBbYGYfHXnVlq9p iuG9A5YgNiFMPYK2kOv8EPZu5U2phVtK1qrD5YrjgJ2d4UZhXAmCTJaNuRBVBHKR2oeV2OlWJ0U+tZmR0TEpE6oeuj1bq5gpJlQ= X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.39 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: <https://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: <85ea3168-cd47-4f06-97f8-5f98ee21c8b9@mrabarnett.plus.com> X-Mailman-Original-References: <oRHyO.142039$bV6e.134076@fx08.ams4> Bytes: 4294 On 2024-08-25 16:12, Gilmeh Serda via Python-list wrote: > Subject explains it, or ask. > > This is a bloody mess: > >>>> s = "123456789" # arrives as str >>>> f"{f'{int(s):,}': >20}" > ' 123,456,789' > You don't need to format twice; you can combine them: >>> s = "123456789" >>> f'{int(s): >20,}' ' 123,456,789' or if you rely on default behaviour: >>> f'{int(s):20,}' ' 123,456,789'