Re: multiple replaces

2005-09-16 Thread D H
You can use python's re.sub function. But also look into full fledged template engines like Cheetah. import re txt=""" whatever the machine with bing 10% of boo is foo """ h1=txt.replace("%","%%") h3 = re.sub("", "%(\\1)s", h1) house="something awfull" tree="something beautifull" print h3

Re: multiple replaces

2005-09-16 Thread Fredrik Lundh
Harald Armin Massa wrote: > sth. like > rpdict={"":"%(tree)s","":"%(house)s","%","%%"} > > for key, value in rpdict.iteritems(): >h1=h1.replace(key, value) > > but ... without the garbage, in one command. > > I guess there are very, very, very wise solution for this problem, but > I do not kno