Fix compatibility with Python 2.6.

This commit is contained in:
Valentin Lorentz 2012-08-13 13:01:50 +00:00
parent 1e794d88d7
commit d2b33a3794

View File

@ -101,7 +101,7 @@ class MultipleReplacer:
# it to a class in Python 3.
def __init__(self, dict_):
self._dict = dict_
dict_ = {re.escape(key): val for key,val in dict_.items()}
dict_ = dict([(re.escape(key), val) for key,val in dict_.items()])
self._matcher = re.compile('|'.join(dict_.keys()))
def __call__(self, s):
return self._matcher.sub(lambda m: self._dict[m.group(0)], s)