Using a function for regular expression substitution

Terry Reedy tjreedy at
Sun Aug 29 17:35:56 CEST 2010

On 8/29/2010 10:22 AM, naugiedoggie wrote:
> Hello,
> I'm having a problem with using a function as the replacement in
> re.sub().
> Here is the function:
> def normalize(s) :
>      return
> urllib.quote(string.capwords(urllib.unquote('provider'))))

To debug your problem, I would start with print(s) in the function and 
if still not clear, unnest the expression and print intermediate results.

Terry Jan Reedy

More information about the Python-list mailing list