Is it Possible to Use Imported Class Methods in A Python Class Definition Without Running All Code In the Imported File?
Question: I am using the PyMOL molecular viewer as a subset of a larger program, and for
ease of reading am breaking up my files like so...

    
    
    ### command1ClassFile.py
    
    class command1Class():
        def command1(self):
            print "do action 1, this requires pymol functions"
    
    ### command2ClassFile.py
    
    class command2Class():
        def command2(self):
            print "do action 2, this also requires pymol functions"
    
    ### mainModule.py
    
    import command1ClassFile, command2ClassFile
    
    class commandsClass(command1Class, command2Class):
        pass
    
    
    class guiClass(parentClass, commandsClass):
        def onLeftClick(self):
            self.command1()
    
        def onRightClick(self):
            self.command2()
    
    # this imports the module as well as launching the program, unfortunately
    import pymol
    pymol.finish_launching()
    

I can't just add "import pymol" to the beginning of the other files, because
that would launch the program multiple times. I can solve this by just using
one .py file, but that leads to an excessively large source file.

I did not catch anyone's interest on the PyMOL mailing list, so I was hoping
there was some other way around this. If not, is there a better way to break
up code? I am used to being spoiled by header files in C++, and the
architecture of Python projects is bit difficult for me to handle properly.

EDIT: For different cases, is using multiple inheritance across files and
dummy compilation classes in this way a good way to structure python projects
with complicated methods?


Answer: If I understand the question correctly, that's what `if __name__ ==
'__main__'` is for.

