Inspecting And Changing Strings In Python

Duncan Booth duncan.booth at invalid.invalid
Wed Apr 29 16:49:10 CEST 2009

"Jim Carlock" <jcarlock at> wrote:

> Anyone here able to provide a link to the Python functions for
> comparing strings and updating strings? I'm looking to do some
> character by character analysis until I find the '@' character
> and then change the rest of the string after that.
You cannot update a string: you must just build a new string with whatever 
content you require.

Something like (assuming your input is in the variable 'input':

def process(input):
  prefix, suffix = input.split('@')
  return prefix + '@' + create_new_suffix(suffix)

Have you been through the tutorial?

Duncan Booth

More information about the Python-list mailing list