Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > True/False formats as 1/0 in a fixed width string

Reply
Thread Tools

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

 
 
Frank Millman
Guest
Posts: n/a
 
      03-27-2013
Hi all

This is a bit of trivia, really, as I don't need a solution.

But someone might need it one day, so it is worth mentioning.

>>> '{}'.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?

Frank Millman

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: True/False formats as 1/0 in a fixed width string Frank Millman Python 0 03-27-2013 09:22 AM
Re: True/False formats as 1/0 in a fixed width string Frank Millman Python 0 03-27-2013 09:14 AM
Re: True/False formats as 1/0 in a fixed width string Dave Angel Python 0 03-27-2013 08:55 AM
Re: True/False formats as 1/0 in a fixed width string Peter Otten Python 0 03-27-2013 08:52 AM
Free Fixed-Width/Fixed-Pitch fonts? johnp HTML 4 05-23-2005 06:14 AM



Advertisments