newbie problem with str.replace

BobAalsma bob.aalsma at aalsmacons.nl
Wed Aug 4 09:25:31 EDT 2010


On Aug 4, 3:22 pm, Anthony Tolle <anthony.to... at gmail.com> wrote:
> On Aug 4, 9:10 am, BobAalsma <bob.aal... at aalsmacons.nl> wrote:
>
> >                         #
> >                         bestandsnaam_nieuw = bestandsnaam
> >                         bestandsnaam_nieuw.replace(KLANTNAAM_OUT,KLANTNAAM_IN)
>
> The replace method does not modify the string (strings are immutable).
>
> You need to use the retun value of the method in an assignment, like
> so:
>
> bestandsnaam_nieuw = bestandsnaam.replace(KLANTNAAM_OUT,KLANTNAAM_IN)
>
> This will not change the value of bestandsnaam

YESS!

Thanks, this is what I wanted to achieve but could not find

Regards,
Bob



More information about the Python-list mailing list