I'm trying to figure out a better solution to do multiple search and replaces in a text file without
having to type:
import re
s = open('filename')
re.sub('vaule1','value2',s)
re.sub('vaule3','value4',s)
etc
I've tried putting all the vaules in a list and doing the replace, but came up short. Any suggestions?
See this recipe which uses the ability of re.sub() to take a callable as the substitution parameter to do what you want.
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81330
Kent
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor