title: How to apply a memorize decorator to an instance method?
body: <p>I'd like to use a memorize decorator on a class method. <code>cExample.pri()</code> calls <code>self.text()</code> but <code>memorize</code> doesn't seem to know about <code>self</code>. When <code>memorize</code> calls <code>self.func(*key)</code> it is missing the <code>cExample</code> obj so it complains about missing args.</p>
  
  <p>How can I change this memorize decorator so that it is able to pass the caller's <code>self</code> to the function?</p>
  
  <p>Python3.5.2</p>
  
  <pre><code>class memorize(dict):
      def __init__(self, func):
          self.func = func
  
      def __call__(self, *args):
          return self[args]
  
      def __missing__(self, key):
          result = self[key] = self.func(*key)
          return result
  
  class cExample():
      @memorize
      def pri(self, text):
          return self.text(text)
  
      def text(self, text):
          return text
  
  c = cExample()
  print(c.pri('hi'))
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>Traceback (most recent call last):
    File "x.py", line 23, in &lt;module&gt;
      print(c.pri('hi'))
    File "x.py", line 7, in __call__
      return self[args]
    File "x.py", line 11, in __missing__
      result = self[key] = self.func(*key)
  TypeError: pri() missing 1 required positional argument: 'text'
  </code></pre>