[Chicago] constant length string manipulation

Lukasz Szybalski szybalski at gmail.com
Thu Nov 29 22:06:57 CET 2007


Hello,
Is there a string function in python that does the following:
I need a string of length 5 char, and I will pass a longer and shorter
string but I always need to get string of length 5.
If my string is longer its easy:
a=b[:5]
but if it is shorter
a=b[:5] will put empty space at the beginning. I need to to put the
space at the end.

Is there another line of code that can do that without if statements?

a='%5s' % b works the same as a=[b:5]


Any ideas?
Lucas


More information about the Chicago mailing list