title: Python Decorators - __call__ in class
body: <p>I was trying to understand Python decorators and I was trying to write an equivalent program to this one:</p>
  
  <pre><code>class myDecorator(object):
     def __init__(self, f):
        print ("inside myDecorator.__init__()")
        f() # Prove that function definition has completed
  
     def __call__(self):
        print ("inside myDecorator.__call__()")
  
  @myDecorator
  def aFunction():
     print ("inside aFunction()")
  
  print ("Finished decorating aFunction()")
  
  aFunction()
  </code></pre>
  
  <p>The problem is I am not understanding how the <code>__call__</code> method of class is being invoked by calling <code>aFunction()</code> in the end.</p>
  
  <p>Is <code>aFunction()</code> being replaced by <code>myDecorator.__call__(aFunction)</code>.
  Can you please help me? How would be an equivalent program without decorators?</p>
  
  <p>Thanks!</p>