rstrip

Tino Wildenhain tino at wildenhain.de
Sat Oct 30 04:28:01 EDT 1999


Hello,

William King wrote:
> 
> Just managed to download and install Python on my PC and was
> trying a few things to start out learning the language... so I guess
> that makes me a NEWBIE....  Anyhow:
> 
> #made a string with leading tabs
> 
>  x  =  "        Test"
> 
try the following:

x = " 		Test		"
string.lstrip(x)
'Test\011\011'
string.rstrip(x)
'\011\011Test'
string.strip(x)
'Test'

now guess why :)

> #used rstrip(x) to eliminate leading tabs (whitespace)
must be a typo. rstrip is of course for the trailing whitespaces

> 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?

Best regards

Tino Wildenhain




More information about the Python-list mailing list