rstrip
Malcolm Tredinnick
malcolmt at smart.net.au
Sat Oct 30 03:40:21 EDT 1999
On Sat, Oct 30, 1999 at 12:20:25AM -0400, William King wrote:
> #made a string with leading tabs
>
> x = " Test"
>
> #used rstrip(x) to eliminate leading tabs (whitespace)
> import string
> string.rstrip(x)
>
> #resulted in
>
> \011\011Test
>
> #lstrip will take away tabs (whitespace) and strip will do same
> #but it appears that rstrip does not on Windows 95
> #is this a bug? or do I have to do something to redefine whitespace?
Everything is fine, don't panic! rstrip removes *trailing* whitespace (i.e.
the 'r' stands for 'right', just like the 'l' in lstrip is 'left'). Do some
experiments with strip, lstrip and rstrip on a string with leading and
trailing whitespace and you'll see the difference.
Cheers,
Malcolm Tredinnick
More information about the Python-list
mailing list