title: Format a decorator in Python
body: <p>RANT - Why do people say 'a decorator is a function that returns another function'? That definition makes no sense, because if that's all a decorator is, why wouldn't you just use the second function and not fool with the first at all? - END RANT</p>
  
  <p>Fortunately, I found a much more sensible definition here:
  <a href="http://thecodeship.com/patterns/guide-to-python-function-decorators/" rel="nofollow">http://thecodeship.com/patterns/guide-to-python-function-decorators/</a></p>
  
  <p>Unfortunately, I still don't understand the examples, like this one:</p>
  
  <pre><code>def get_text(name):
     return "lorem ipsum, {0} dolor sit amet".format(name)
  
  def p_decorate(func):
     def func_wrapper(name):
         return "&lt;p&gt;{0}&lt;/p&gt;".format(func(name))
     return func_wrapper
  
  my_get_text = p_decorate(get_text)
  
  print my_get_text("John")
  
  #Outputs "&lt;p&gt;lorem ipsum, John dolor sit amet&lt;/p&gt;"
  </code></pre>
  
  <p>Note, the post is more than two years old and the authors have not responded to any of the comments.</p>
  
  <p>Here's my question: Why doesn't it output</p>
  
  <pre><code>"&lt;p&gt;John&lt;/p&gt;"
  </code></pre>
  
  <p>or an error? How does the whole string get inside the p tags instead of just the name?</p>