Re: Question about re.sub and callables

2005-12-30 Thread Fredrik Lundh
"Guyon Morée wrote: > I can provide re.sub with a callable, but this will only be called > with a match object, it's not possible to give it any of the other > params. > > The solution I came up with to tackle this is with some funny globals, > which doesnt feel 'right': > > -

Re: Question about re.sub and callables

2005-12-29 Thread Guyon Morée
Thanks, I just *assumed* I needed the globals to reach the vars in the nested function. This makes my code a l ot cleaner :) cheers, Guyon Morée http://gumuz.looze.net/ -- http://mail.python.org/mailman/listinfo/python-list

Re: Question about re.sub and callables

2005-12-29 Thread skip
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])")

Question about re.sub and callables

2005-12-29 Thread Guyon Morée
I have a function with some params including some data to be used with re.sub and some other data which i want to use in the replacement. I can provide re.sub with a callable, but this will only be called with a match object, it's not possible to give it any of the other params. The solution I c