title: how to validate arguments using decorators in python
body: <p>I need to validate two given inputs before I call the <code>add</code> function: Ff any input is not an integer I should get <code>invalid input</code> or <code>error</code> message, if both are integers I should get the sum.</p>
  <pre><code>import re
  
  def my_dec(arg1,arg2):
       x = re.compile(r&quot;[^0-9]&quot;)
       if x.search(arg1) and x.search(arg2):
          return add(a,b)
       else:
           print(&quot;invalid input&quot;)
  
  @my_dec(arg1,arg2)
  def add(a,b):
     return a + b
  
  print(add(2,3))
  </code></pre>
  <p>I get <code>function not defined</code> errors in loops, but I don't know how to overcome it.</p>