Guyon> The solution I came up with to tackle this is with some funny
Guyon> globals, which doesnt feel 'right':
...
Guyon> Is there any other way to do this?
You've almost got it right. Just lose the "global":
def test(data, pre, post):
p = re.compile("([0-9])")
def repl(m):
return pre + m.group(1) + post
print p.sub(repl, data)
For a full explanation, google for "python nested scopes".
Skip
--
http://mail.python.org/mailman/listinfo/python-list
