[Answer]-Include functions in class from another file in python

1👍

Python lets you inherit from multiple classes, so go ahead an put your methods into a separate base class and inherit from it, too.

Also, python lets you pull in from other files with the import statement.

0👍

Although there are several ways to do this, the first one I would recommend is to create mixin classes from both files.

So in your main module

import myfunctions1
import myfunctionsA
class SOAPService(ServiceBase,myfunctions1.mixin,myfunctionsA.mixin):
    pass

and in your included modules myfunctions1, myfunctionA etc.

class mixin:
    def myfunction1(self):
        return
    def myfunction2(self, arg1):
        return

Leave a comment