title: How to provide *args and **kwargs to __call__ using abbreviated notation of class based decorators?
body: <p>I have a question about class based decorators in python and how arguments 
  can be provided while decorating a given function.</p>
  
  <p>Consider the following prototype:</p>
  
  <pre><code>class MyDecoratorClass:
      def __init__(self, *args, **kwargs):
          # . . . Any code that is needed here
          pass
  
      def __call__(self, fun_to_decorate, *args, **kwargs):
          def inner(*args, **kwargs):
              # . . . Any code that is needed here
              return fun_to_decorate(*args, **kwargs)
          return inner
  </code></pre>
  
  <p>And consider the function to be decorated:</p>
  
  <pre><code>def myfun(*args, **kwargs):
      print("myfun was called")
  </code></pre>
  
  <p>One way of decorating the above mentioned function would be the following:</p>
  
  <ul>
  <li><p><strong>Step 1:</strong> Creating an instance of the decorator class. This will call the 
  constructor, that is, <code>__init__</code> . If I pass any argument 
  below, it would go "only once" inside <code>__init__</code> , when the instance is 
  created.</p>
  
  <p>decorator = MyDecoratorClass()</p></li>
  <li><p><strong>Step 2</strong>: Specifying which function to be decorated, and if required provide 
  an argument list which will correspond to <code>*args</code> and/or <code>**kwargs</code> in 
  <code>__call__</code> signature as it has been defined in the class.</p></li>
  </ul>
  
  <p><code>decorated_fun = decorator(myfun, arg1, arg2)</code></p>
  
  <ul>
  <li><p><strong>Step 3:</strong> Finally call the decorated function and if required provide an 
  argument list for the function itself, which if provided, corresponds to 
  the list of the formal parameters of the inner function inside the <code>__call__</code> function.
  If I understand correctly, the namespace of inner formal parameters are distinct from the namespace of <code>__call__</code> formal parameters </p>
  
  <p>decorated_fun(...)</p></li>
  </ul>
  
  <p>And this works. However if I want to use the abbreviated notation I have 
  to write something like this:</p>
  
  <pre><code>@MyDecoratorClass(arg1, arg2)
  def myfun(*args, **kwargs):
      print("myfun was called")
  </code></pre>
  
  <p>In the example above I passed the very same two positional arguments <code>arg1</code> and <code>arg2</code>. Now 
  the problem is, that these two arguments are not <code>(*args, **kwargs)</code> specified 
  in <code>__call__</code> but actually those specified in <code>__init__</code></p>
  
  <p>So my question is, when we use the abbreviated notation for decorating a 
  function via a class based decoration with arguments, how to access <strong>call</strong>
  argument list in order to provide those arguments <strong>for each</strong> decorated function?</p>