title: Passing a function to re.sub in Python
body: <p>I have strings that contain a number somewhere in them and I'm trying to replace this number with their word notation (ie. 3 -> three). I have a function that does this. The problem now is finding the number inside the string, while keeping the rest of the string intact. For this, I opted to use the <code>re.sub</code> function, which can accept a "callable". However, the object passed to it is the internal <code>_sre.SRE_Match</code> and I'm not sure how to handle it. My function accepts a number or its string representation.</p>
  
  <p>How should I write some helper function which can be used to bridge the <code>re.sub</code> call with my function doing the required processing? Alternatively, is there a better way to do what I want?</p>