title: Python subclass method to inherit decorator from superclass method
body: <p>I have a superclass that has a retrieve() method, and its subclasses each implement their own retrieve() method.  I'd like every retrieve() method to be decorated to cache the return value when it receive the same args, without having to decorate the method in every subclass.</p>
  
  <p>Decorators don't seem to be inherited.  I could probably call the superclass's method which would in turn set the cache, but currently my superclass raises a NotImplemented exception, which I like.</p>
  
  <pre><code>import json
  import operator
  from cachetools import cachedmethod, TTLCache
  
  def simple_decorator(func):
      def wrapper(*args, **kwargs):
          #check cache
          print("simple decorator")
          func(*args, **kwargs)
          #set cache
      return wrapper
  
  
  class AbstractInput(object):
      def __init__(self, cacheparams = {'maxsize': 10, 'ttl': 300}):
          self.cache = TTLCache(**cacheparams)
          super().__init__()
  
      @simple_decorator
      def retrieve(self, params):
          print("AbstractInput retrieve")
          raise NotImplementedError("AbstractInput inheritors must implement retrieve() method")
  
  class JsonInput(AbstractInput):
      def retrieve(self, params):
          print("JsonInput retrieve")
          return json.dumps(params)
  
  class SillyJsonInput(JsonInput):
      def retrieve(self, params):
          print("SillyJsonInput retrieve")
          params["silly"] = True
          return json.dumps(params)
  
  </code></pre>
  
  <p>Actual results:</p>
  
  <pre><code>&gt;&gt;&gt; ai.retrieve(params)
  ai.retrieve(params)
  simple decorator
  AbstractInput retrieve
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "&lt;string&gt;", line 8, in wrapper
    File "&lt;string&gt;", line 22, in retrieve
  NotImplementedError: AbstractInput inheritors must implement retrieve() method
  &gt;&gt;&gt; ji.retrieve(params)
  ji.retrieve(params)
  JsonInput retrieve
  '{"happy": "go lucky", "angry": "as a wasp"}'
  </code></pre>
  
  <p>Desired results:</p>
  
  <pre><code>&gt;&gt;&gt; ai.retrieve(params)
  ai.retrieve(params)
  simple decorator
  AbstractInput retrieve
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "&lt;string&gt;", line 8, in wrapper
    File "&lt;string&gt;", line 22, in retrieve
  NotImplementedError: AbstractInput inheritors must implement retrieve() method
  &gt;&gt;&gt; ji.retrieve(params)
  simple decorator
  ji.retrieve(params)
  JsonInput retrieve
  '{"happy": "go lucky", "angry": "as a wasp"}'
  </code></pre>