title: Python: renaming a superclass's methods and their function-scope references
body: <p>Consider the following example:</p>
  
  <pre><code>class Company():
  
      def hireEmployee():
  
      def fireEmployee():
  
      def promoteEmployee():
  
      etc...
  
  class EngineeringFirm(Company):
      pass
  
  class PaintingFirm(Company):
      pass
  </code></pre>
  
  <p>Suppose the Company class has a lot more methods. What if I want to rename these methods from the superclass so I can get the following:</p>
  
  <pre><code>class EngineeringFirm(Company):
  
      def hireEngineer():
      ...
  
  class PaintingFirm(Company):
  
      def hirePainter():
      ...
  </code></pre>
  
  <p>...and so on. While using 'Employee' in this scenario really wouldn't hurt a bit, this is really just  to illustrate the idea. How would I go about it? </p>
  
  <p>My idea was to use a classFactory function that would take the type of employee as argument and generate a Company class, while a metaclass would handle the renaming by iterating through the attribute dictionary and replacing 'Employee' with said type.</p>
  
  <pre><code>class EngineeringFirm(companyFactory('Engineer'))
      ...
  </code></pre>
  
  <p>The only problem is this: What if the methods inside of Company make calls to one another by the default 'Employee' names? This is where I'm stumped. I had the idea that the metaclass involved in renaming the methods could also get the source of each function (via the inspect module) and search if a known method attribute is found within and, if so, replace that part and create a new function via exec and assigning it back to the right attribute key. </p>
  
  <p>...But that really seems kinda of hacky. I am open to alternatives and although I realize there may be design-related issues with the question (I am open to suggestions on that front as well) I would be interested in finding out if this problem has a more elegant solution.</p>
  
  <p>Thanks!</p>
  
  <p><strong>Edit: another solution</strong></p>
  
  <p>For the sake of argument, I'll assume for a moment that the code above is really what I'm working with; I figured I could address some of the concerns in the comments with another solution I had in mind, one I'd already considered and put away for reasons I'll explain.</p>
  
  <p>If the <code>Firm</code> classes inherited from Company and I wished to maintain a identical interface (as one usually would in a case like this to allow dynamic calls to <code>hire()</code> or <code>promote()</code>, etc) I could implement a <code>__getattribute__</code> that accepts <code>HirePainter()</code> (by accessing the original Employee method) while still allowing any other interface to use the <code>HireEmployee()</code> if necessary. </p>
  
  <p>I wonder, supposing it's alright to extend my question, if this is something that would be considered bad practice if, say, I planned to do this because I thought that the code inside <code>PaintingFirm</code> would benefit in readability? Again, I realize this example is horrid in that readability here really does not seem to benefit in any way whatsoever, but suppose it did?</p>
  
  <p>(The only reason I didn't suggest this idea in the first place is that my <code>__getattribute__</code> already handles quite a bit, and adding extra noise to it didn't feel that appealing. Still, I could work it in, but this is a question I had to ask in case there were more magical (but not hacky) solutions out there..)</p>