Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsfeed.xs4all.nl!newsfeed4.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.013 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:string': 0.09; 'width': 0.09; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'thanks,': 0.17; 'wrote:': 0.18; '>>>': 0.22; 'header:User- Agent:1': 0.23; 'instead.': 0.24; 'string,': 0.24; 'subject:/': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'fixed': 0.29; "skip:' 10": 0.31; '>>>>': 0.31; 'but': 0.35; 'there': 0.35; 'work?': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'frank': 0.68; "'true'": 0.84; 'otten': 0.84; 'subject:True': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Frank Millman Subject: Re: True/False formats as 1/0 in a fixed width string Date: Wed, 27 Mar 2013 11:14:00 +0200 References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: 197.87.50.233 User-Agent: Mozilla/5.0 (Windows NT 5.2; rv:14.0) Gecko/20120713 Thunderbird/14.0 In-Reply-To: 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: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1364375648 news.xs4all.nl 6884 [2001:888:2000:d::a6]:40174 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:41995 On 27/03/2013 10:52, Peter Otten wrote: > Frank Millman wrote: > >> >>> '{}'.format(True) >> 'True' >> >>> '{:<10}'.format(True) >> '1' >> >> One might want to format True/False in a fixed width string, but it >> returns 1/0 instead. Is there any way to make this work? > >>>> "{!s:<10}".format(True) > 'True' > > Works perfectly. Thanks, Peter Frank