title: Whether the return value of a function modified by python decorator can only be Nonetype
body: <p>I wrote a decorator that gets the runtime of the program, but the function return value becomes Nonetype.</p>
  
  <pre><code>def gettime(func):
      def wrapper(*args, **kw):
          t1 = time.time()
          func(*args, **kw)
          t2 = time.time()
          t = (t2-t1)*1000
          print("%s run time is: %.5f ms"%(func.__name__, t))
  
      return wrapper
  </code></pre>
  
  <p>If I don't use the decorator, the return value is correct.</p>
  
  <pre><code>A = np.random.randint(0,100,size=(100, 100))
  B = np.random.randint(0,100,size=(100, 100))
  def contrast(a, b):
      res = np.sum(np.equal(a, b))/(A.size)
      return res
  
  res = contrast(A, B)
  print("The correct rate is: %f"%res)
  </code></pre>
  
  <p>The result is:<code>The correct rate is: 0.012400</code></p>
  
  <p>And if i use the decorator:</p>
  
  <pre><code>@gettime
  def contrast(a, b):
      res = np.sum(np.equal(a, b))/len(a)
      return res
  
  res = contrast(A, B)
  print("The correct rate is: %f"%res)
  </code></pre>
  
  <p>There will report a error:</p>
  
  <pre><code>contrast run time is: 0.00000 ms
  </code></pre>
  
  <p><code>TypeError: must be real number, not NoneType</code></p>
  
  <p>Of course, if I remove the <code>print</code> statement, I can get the correct running time, but the <code>res</code> accepts the Nonetype.</p>