title: Importing methods for a Python class
body: <p>I wonder if it's possible to keep methods for a Python class in a different file from the class definition, something like this:</p>
  
  <p><code>main_module.py:</code></p>
  
  <pre><code>class Instrument(Object):
      # Some import statement?
      def __init__(self):
          self.flag = True
      def direct_method(self,arg1):
          self.external_method(arg1, arg2)
  </code></pre>
  
  <p><code>to_import_from.py:</code></p>
  
  <pre><code>def external_method(self, arg1, arg2):
      if self.flag:
          #doing something
  #...many more methods
  </code></pre>
  
  <p>In my case, <code>to_import_from.py</code> is machine-generated, and contains many methods. I would rather not copy-paste these into main_module.py or import them one by one, but have them all recognized as methods of the Instrument class, just as if they had been defined there:</p>
  
  <pre><code>&gt;&gt;&gt; instr = Instrument()
  &gt;&gt;&gt; instr.direct_method(arg1)
  &gt;&gt;&gt; instr.external_method(arg1, arg2)
  </code></pre>
  
  <p>Thanks!</p>