title: How to call the original method when it is monkey-patched?
body: <p>I have a class in the main project I don't want to change.</p>
  
  <pre><code>class A():
      def __init__(self, firstname, lastname):
          self.firstname = firstname
          self.lastname = lastname
  
      def name(self):
          # this method could be much more complex
          return self.lastname.upper()
  </code></pre>
  
  <p>I'm trying to build a plugin mechansim. So far so good, I have an extension point like this:</p>
  
  <pre><code>if __name__ == '__main__':
      ''' The main project has an extension point that allows me to do'''
      # for each class extension such as AExtended:
      A.name = AExtended.name
      ''' After the extensions are loaded, some behaviours may be changed'''
      a = A("John", "Doe")
      print(a.name())
  </code></pre>
  
  <p>A plugin can be written like this:</p>
  
  <pre><code>class AExtended(A):
      ''' This is an extension I provide through a plugin mechanism
      '''
      def name(self):
          return self.firstname + ' ' + self.lastname.upper()
  </code></pre>
  
  <p>This all works very well. I now get "John DOE".</p>
  
  <p>My problem is that the original <code>name()</code> method can be quite complex. In other words, I can't afford to call <code>self.lastname.upper()</code> in the <code>AExtended</code>. I'd like to call the "super" method, which does not exist any more, because it has been overwritten.</p>
  
  <p>How can I change my code, in order to achieve something like this:</p>
  
  <pre><code>class AExtended(A):
      def name(self):
          # I'm looking for a way to call the base implementation that was in A.name()
          return self.firstname + ' ' + parent.name()
  </code></pre>
  
  <p>Thanks for your help!</p>
  
  <p>Edit: Some explanations of what I try to do.</p>
  
  <ul>
  <li>I want the plugin to patch the behaviour of <code>A</code>. I can't afford to change existing consumers of A</li>
  <li>There are many classes like <code>A</code> that could be changed, I'd like plugins to have full control and responsibility</li>
  <li>It's true <code>AExtended</code> does not have to inherit from <code>A</code>, but it was an easy way to access <code>self.firstname</code>. I have no problem following a different design pattern if it can help.</li>
  </ul>
  
  <p>I have a workaround, but it's not very elegant and hard to generalize</p>
  
  <pre><code>class AExtended(A):
      def name(self):
          # I'm looking for a way to call the base implementation that was in A.name()
          return self.firstname + ' ' + self.parentname()
  #in main
  A.parentname = A.name
  A.name = AExtended.name
  </code></pre>