BGE python module mode entry points confusion

I have been working with module mode for scripting for awhile, and one issue keeps rearing its ugly head. The following code generates the error KX_GameObject has no attribute main



from bge import logic, types


class selector (types.KX_GameObject):
    
    def __init___(self):
        self.cont = logic.getCurrentController()
        self.own = cont.owner
    
    def idle():
        print("why dosn't this work?") 
    
                        
           
         
def main(cont):
        own = cont.owner
        if "init" not in own:
            own["init"] = True

            own(selector)
        else:
            own.main = own.idle  



I have read up on module mode and basic python quite a bit to try and solve this, but i am still not sure what conditions cause this. I deeply apologize if this is an RTFM question, but this has been driving me bonkers for weeks! any help on what i am missing wold be nice.

The object doesn’t maintain a reference to the script - main doesn’t belong to the KX_GameObject.
When wrapping / mutating game objects, you still need to call into an entry point.



from bge import logic, types


class Selector (types.KX_GameObject):
    
    def __init___(self, _old_reference):
        self.state = self.idle

    def update(self):
        self.state()   

    def idle():
        print("why does this work ;)") 
    
           
def main(cont):
        own = cont.owner

        if not isinstance(own, Selector):
            own = Selector(own)

        own.update()