newbie problem with str.replace

Daniel da Silva ddasilva at
Thu Aug 5 08:26:01 CEST 2010

               for bestandsnaam in dirs and files:
is probably not doing what you want. Use + to concatenate  lists.


On Wed, Aug 4, 2010 at 6:30 AM, Mike Kent <mrmakent at> wrote:

> On Aug 4, 9:10 am, BobAalsma <bob.aal... at> wrote:
> > I'm working on a set of scripts and I can't get a replace to work in
> > the script - please help.
> >
> bestandsnaam_nieuw.replace(KLANTNAAM_OUT,KLANTNAAM_IN)
> I'm not sure what you are intending to do here, but string.replace
> does not do its replacement in-place.  It returns a copy of the
> original string, with the replacement done in the copy.  You are not
> assigning the string returned by string.replace to anything,
> therefore, it is immediately thrown away.
> Secondly, and this is just a guess, but since you are doing the
> string.replace inside of an os.walk loop, you appear to be trying to
> do a filename change.  I hope you realize that this will in no way
> change the name of the file *on disk*; it will only change it in
> memory.
> --
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list