Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #41995

Re: True/False formats as 1/0 in a fixed width string

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 <python-python-list@m.gmane.org>
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 <frank@chagford.com>
Subject Re: True/False formats as 1/0 in a fixed width string
Date Wed, 27 Mar 2013 11:14:00 +0200
References <kiub99$q9u$1@ger.gmane.org> <kiubvv$jh$1@ger.gmane.org>
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 <kiubvv$jh$1@ger.gmane.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.3800.1364375648.2939.python-list@python.org> (permalink)
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

Show key headers only | View raw


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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: True/False formats as 1/0 in a fixed width string Frank Millman <frank@chagford.com> - 2013-03-27 11:14 +0200

csiph-web