substitution
superpollo
utente at esempio.net
Mon Jan 18 05:21:54 EST 2010
superpollo ha scritto:
> hi.
>
> what is the most pythonic way to substitute substrings?
>
> eg: i want to apply:
>
> foo --> bar
> baz --> quux
> quuux --> foo
>
> so that:
>
> fooxxxbazyyyquuux --> barxxxquuxyyyfoo
>
> bye
i explain better:
say the subs are:
quuux --> foo
foo --> bar
baz --> quux
then i cannot apply the subs in sequence (say, .replace() in a loop),
otherwise:
fooxxxbazyyyquuux --> fooxxxbazyyyfoo --> barxxxbazyyybar -->
barxxxquuxyyybar
not as intended...
More information about the Python-list
mailing list