title: Python decorator works with staticmethod. But fails with 2 static methods. Why?
body: <p>Here is my python code. I have a class <code>MyClass</code> with two static methods: <code>my_method1</code> and <code>my_method2</code>. Both methods are wrapped with a decorator called <code>exception_handler</code>.</p>
  
  <pre><code>from functools import wraps
  import sys
  
  def exception_handler(function):
      @wraps(function)
      def decorator(self, *args, **kwargs):
          try:
              return function(self, *args, **kwargs)
          except Exception, e:
              print "EXCEPTION!: %s" % e
              sys.exit(-1)
      return decorator
  
  
  class MyClass:
      @staticmethod
      @exception_handler
      def my_method1(a, b, c,):
          return "X"
  
      @staticmethod
      @exception_handler
      def my_method2(e, f, g,):
          print "Y"
          return MyClass.my_method1(a=e, b=f, c=g)
  
  print "Trying my_method1"
  print MyClass.my_method1(1, 2, 3)
  
  print ""
  print "Trying my_method2"
  print MyClass.my_method2(1, 2, 3)
  </code></pre>
  
  <p>When I run this code, I get the following:</p>
  
  <pre><code>Trying my_method1
  X
  
  Trying my_method2
  Y
  EXCEPTION!: decorator() takes at least 1 argument (0 given)
  </code></pre>
  
  <p>Why does the decorator fail in the second instance and how can I get around it? </p>
  
  <p>It seems like the decorator fails when decorated method is a static method being called by another static method. But why this would happen makes no sense to me.</p>