title: Working of a Decorator
body: <p>I have a question regarding the workings of a decorator. I would like to explain my problem using an example</p>
  
  <p>The code I implemented to understand decorators</p>
  
  <pre><code>import sys
  import inspect
  def entryExit(f):
      def new_f(self,*args, **kwargs):
          print "Entering", f.__name__,self.__class__.__name__,inspect.getargspec(f).args[1:] 
          f(self,*args)        
          print "Exited", f.__name__,self.__class__.__name__,inspect.getargspec(f).args[1:]        
      return new_f
  
  
  class A:
      @entryExit
      def move(self,g,h):
          print "hello"        
          print g,h            
  
      @entryExit    
      def move1(self,m,n):
          print "hello"        
          print m,n
          return m
  a=A()
  a.move(5,7)
  h=a.move1(3,4)
  print h
  </code></pre>
  
  <p>The output of this code is</p>
  
  <pre><code>Entering move A ['g', 'h']
  hello
  5 7
  Exited move A ['g', 'h']
  Entering move1 A ['m', 'n']
  hello
  3 4
  Exited move1 A ['m', 'n']
  None
  </code></pre>
  
  <p>The last line of the output displays <code>None</code>. But the actual meaning of the method is changed by using decorators. The return statement in the method <code>move1</code> was not executed. The actually output I need would be</p>
  
  <pre><code>Entering move A ['g', 'h']
  hello
  5 7
  Exited move A ['g', 'h']
  Entering move1 A ['m', 'n']
  hello
  3 4
  Exited move1 A ['m', 'n']
  3
  </code></pre>
  
  <p>So did I make any mistake while creating a decorator or the  decorators always ignores the return statement in a function?</p>