title: Python - Use external function as class method
body: <p>Say I have some very long function <code>module.my_function</code> that's something like this:</p>
  
  <pre><code>def my_function(param1,param2,param3='foo',param4='bar',param5=None,...)
  </code></pre>
  
  <p>With a large number of args and keyword args. I want this function to be usable both as a part of module <code>module</code> and as a class method for <code>myClass</code>. The code for the function will remain exactly the same, but in <code>myClass</code> a few keyword args may take different default values. </p>
  
  <p>What's the best way of doing this? Previously I was doing something like:</p>
  
  <pre><code>class myCLass(object):
      def __init__(self,...
      def my_function(self, param1,param2,param3='hello',param4='qaz',param5=['baz'],...):
          module.my_function(param1,param2,param3=param3,param4=param4,param5=param5,...)
  </code></pre>
  
  <p>It seems a little silly to write all these arguments that many times, especially with a very large number of arguments. I also considered doing something like <code>module.my_function(**locals())</code> inside the class method, but I'm not sure how to handle the <code>self</code> argument and I don't know if this would lead to other issues. </p>
  
  <p>I could just copy paste the entire code for the function, but that doesn't really seem very efficient, when all that's changing is a few default values and the code for <code>my_function</code> is <em>very</em> long. Any ideas?</p>