Optimization help needed: Search and Replace using dictionary of parameters
Jeff Hinrichs
jlh at home.com
Tue Jan 1 15:10:52 EST 2002
> I dont remember who posted this snippet on c.l.py a long time ago, but it
> works like a charm, so I havn't bothered changing it.
...
> if __name__ == '__main__':
>
> r = MultiReplace({"spam": "eggs", "spam": "eggs"})
> print r.replace("spam&eggs")
> ## eggs&spam
This actually outputs eggs&eggs, to get the desired output of spam&eggs the
dictionary needs to be modified to:{"spam": "eggs", "eggs": "spam"}
More information about the Python-list
mailing list