[Tutor] Conflicted

Raymond Hettinger python@rcn.com
Sat, 6 Apr 2002 21:05:54 -0500


The implication is, of course, that you should never
let your name become mud because you'll never live it down ;)

Raymond

----- Original Message -----
From: "Sean 'Shaleh' Perry" <shalehperry@attbi.com>
To: "Eve Kotyk" <e.kotyk@shaw.ca>
Cc: <tutor@python.org>
Sent: Saturday, April 06, 2002 7:58 PM
Subject: Re: [Tutor] Conflicted


> >
> > I am however not quite clear as to why the whole line is being replace
> > rather than just the string requested.    >
>
> >>> s = 'My name is mud'
> >>> s.replace('mud', 'Sean')
> 'My name is Sean'
> >>> s
> 'My name is mud'
>
> s.replace returns the new string.  Keep this mantra in memory at all times
when
> coding in python -- "A string is a constant, I can not change it".  The
only
> way to change a string is to make a new one.
>
> line = line.replace(x, '') # for instance.
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>