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

From Frank Millman <frank@chagford.com>
Subject Re: True/False formats as 1/0 in a fixed width string
Date 2013-03-27 11:14 +0200
References <kiub99$q9u$1@ger.gmane.org> <kiubvv$jh$1@ger.gmane.org>
Newsgroups comp.lang.python
Message-ID <mailman.3800.1364375648.2939.python-list@python.org> (permalink)

Show all headers | 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