title: Python decorator composition
body: <p>Below is an example code demonstrates how decorators work. It takes a function <code>get_text(name)</code> and wraps it with a function <code>p_decorate(func)</code>. </p>
  
  <p>I have trouble understanding how the function p_decorate knows that the parameter <code>name</code> is a supplied argument of <code>func</code>? Since <code>func</code> in definition of <code>p_decorate</code> has no arguments? Can someone please explain. So far I know how decorators work with functions without parameters, but this is causing me a headache. </p>
  
  <pre><code>def get_text(name):  #This is fine                                                                    
      return "lorem ipsum, {0} dolor sit amet".format(name)                                
  
  def p_decorate(func):                                                                    
      def func_wrapper(name):   #How does it know that name is part of func?                                                           
          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") 
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>&lt;p&gt;lorem ipsum, John dolor sit amet&lt;/p&gt;
  </code></pre>