title: Python replace string pattern with output of function
body: <p>I have a string in Python, say <code>The quick @red fox jumps over the @lame brown dog.</code></p>
  
  <p>I'm trying to replace each of the words that begin with <code>@</code> with the output of a function that takes the word as an argument.</p>
  
  <pre><code>def my_replace(match):
      return match + str(match.index('e'))
  
  #Psuedo-code
  
  string = "The quick @red fox jumps over the @lame brown dog."
  string.replace('@%match', my_replace(match))
  
  # Result
  "The quick @red2 fox jumps over the @lame4 brown dog."
  </code></pre>
  
  <p>Is there a clever way to do this?</p>