On Mon, 9 May 2005 15:48:14 +0200, "Fredrik Lundh" <[EMAIL PROTECTED]> wrote:
>Bill Mill wrote:
>
> for rep in L:
>> ... source = source.replace(token, rep, 1)
>
>here's another way to do it:
>
L = ["11", "22", "33"]
S = "xyzzy text we've got xyzzy text xyzzy yeah yeah yeah"
Thank you.
--
http://mail.python.org/mailman/listinfo/python-list
Well, not to be left out, here is a pyparsing solution. But this looks
suspiciously like some form of mail-merge or templating application.
Google for 'python templating' for existing approaches to this problem.
Interestingly, using an iterator of L sidesteps a number of other
problems. My origi
Bill Mill wrote:
for rep in L:
> ... source = source.replace(token, rep, 1)
here's another way to do it:
>>> L = ["11", "22", "33"]
>>> S = "xyzzy text we've got xyzzy text xyzzy yeah yeah yeah"
>>> L.reverse()
>>> re.sub("xyzzy", lambda x: L.pop(), S)
"11 text we've got 22 text 33 yeah
[EMAIL PROTECTED] wrote:
> I would like to replace string with different values,
> For example :
> source = 'kode1 bla bla kode1 bla kode1'
> I have a list with each member will replace each of kode1.
> L = [11,22,33]
> So the new source will become:
> newsource = '11 bla bla 22 bla 33'
>
> How c
[EMAIL PROTECTED] wrote:
> I would like to replace string with different values,
> For example :
> source = 'kode1 bla bla kode1 bla kode1'
> I have a list with each member will replace each of kode1.
> L = [11,22,33]
> So the new source will become:
> newsource = '11 bla bla 22 bla 33'
Here's on
On 9 May 2005 06:23:41 -0700, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I would like to replace string with different values,
> For example :
> source = 'kode1 bla bla kode1 bla kode1'
> I have a list with each member will replace each of kode1.
> L = [11,22,33]
> So the new source
Hello,
I would like to replace string with different values,
For example :
source = 'kode1 bla bla kode1 bla kode1'
I have a list with each member will replace each of kode1.
L = [11,22,33]
So the new source will become:
newsource = '11 bla bla 22 bla 33'
How can I do it ? I tried to find using s