How you chomp in python

Jeremy Dillworth j_k_wd at bellsouth.net
Fri Sep 19 22:36:41 EDT 2003


Strings in Python are immutable.

Any time you perform an operation that seems like it might change a string, 
what really happens is a new string is returned.

this:
string.rstrip(build_number)

returns your chomped string, but it's not being assigned to anything.  'Poor 
thing never had a chance ... :)

You probably want:

build_number = string.rstrip(build_number)

or the more preferred way:

build_number = build_number.rstrip()



On Friday 19 September 2003 9:43 pm, Fernando Armenta wrote:
> How you cut off the ^M at the end of a line? rstrip is not working.
>
>
>
> string.rstrip(build_number)
>
>
>
> thanks,
>
>
>
> -F






More information about the Python-list mailing list