title: Class decorators vs function decorators
body: <p>In python there are two ways to declare decorators:</p>
  
  <p><strong>Class based</strong></p>
  
  <pre><code>class mydecorator(object):
      def __init__(self, f):
          self.f = f
  
      def __call__(self, *k, **kw):
          # before f actions
          self.f(*k, **kw)
          # after f actions
  </code></pre>
  
  <p><strong>Function based</strong></p>
  
  <pre><code>def mydecorator(f):
      def decorator(*k, **kw):
          # before f actions
          f(*k, **kw)
          # after f actions
  
      return decorator          
  </code></pre>
  
  <p>Is there any difference between these declarations? 
  In which cases each of them should be used?</p>