[Chicago] constant length string manipulation
Tim Ottinger
tottinge at gmail.com
Mon Dec 3 18:51:23 CET 2007
def padWithTruncate(value, width, fillchar=" "):
truncated = str(value)[:width]
return truncated.ljust(width,fillchar)
And of course, I echo the concern about truncating *values*. It's a
very dangerous thing to do.
Truncating strings, of course, has different but similar concerns.
cheers.
Lukasz Szybalski wrote:
> On Nov 29, 2007 3:29 PM, Cosmin Stejerean <cstejerean at gmail.com> wrote:
>
>> b.ljust(5)[:5]
>>
>
> a='1234567890' or a='123'
> b=a.ljust(5)[:5]
>
> so I guess ljust will do.
> Thanks.
> Lucas
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> http://mail.python.org/mailman/listinfo/chicago
>
More information about the Chicago
mailing list