title: creating decorator out of another decorator (python)
body: <p>After spending several hours on the topic of decorators in python, I still have two issues. </p>
  
  <p>First; if you have decorator without argument, sytntax is like this:</p>
  
  <pre><code>@decorator
  def bye():
      return "bye"
  </code></pre>
  
  <p>which is just a syntactic sugar and is same as this</p>
  
  <pre><code>bye = decorator(bye)
  </code></pre>
  
  <p>but if I have a decorator with argument:</p>
  
  <pre><code>@decorator(*args)
  def bye():
      return "bye"
  </code></pre>
  
  <p>How does "no-sugar" version looks like? Is the function passed inside as one of the arguments?</p>
  
  <pre><code>bye = decorator("argument", bye)
  </code></pre>
  
  <p>Second issue(which is related to the first, yet more practical example);</p>
  
  <pre><code>def permission_required(permission):
      def wrap(function):
          @functools.wraps(function)
              def wrapped_func(*args, **kwargs):
                  if not current_user.can(permission):
                      abort(403)
                  return function(*args, **kwargs)
              return wrapped_function
      return wrap
  
  def admin_required(f):
      return permission_required(Permission.ADMINISTER)(f)
  </code></pre>
  
  <p>Here <strong>permission_required</strong> decorator is passed to a return statement of newly created decorator named <strong>admin_required</strong>. I have no idea how this works. Mainly the return statement where we returning original decorator + the function(in strange syntax). Can someone elaborate on this? - details are extremely welcome</p>