View Single Post
Old 02-19-2012, 02:27 AM   #251
pchrist7
Addict
pchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animalspchrist7 is kind to children and small, furry animals
 
pchrist7's Avatar
 
Posts: 385
Karma: 6514
Join Date: Aug 2010
Location: Denmark
Device: Kindle 3 3G+Wifi, Oasis
Because pct is an integer ?

Quote:
Originally Posted by razorsoup View Post
I am following this post by pchrist7 to add a read status column to Calibre. I would like to pad the percentages with spaces on the left to aid in sorting but cannot figure out how to do so. I have tried changing the line to
Code:
return is_reading_str + ': ' + pct.rjust(3) + '%'
and
Code:
return is_reading_str + ': ' + pct.rjust(3, ' ') + '%'
but neither of these seem to work. If I use
Code:
return is_reading_str + ': ' + pct.rjust(3, '0') + '%'
the percentage is padded with zeros, so the padding seems to work. I guess something is stripping the extra spaces? Is there any way to do what I am trying?

Original post by pchrist7:
Spoiler:

Hi razorsoup
I'm not that much of a python programmer, but I suspect python only let's you use 0 padding since pct is an integer and rjust is a string function ?
If that's the way it works, you could try to convert pct from int to string before using rjust. Sorry, don't know how to do this. Google might help you.
If you figure it out, please enlighten us all in this thread
Cheers, Per
pchrist7 is offline   Reply With Quote