Is there a way to enter an object's namespace so that I can use its methods as though they were global? I was thinking of something using the with statement.
class Bar():
    
    def methodA(self):
        # do stuff
    def methodB(self):
        # do more stuff
    def __enter__(self):
        # somehow enter object namespace / transfer methods into global namespace
    def __exit__(self, *args):
        # exit object namespace / get rid of globalized methods
foo = Bar()
with foo:
    methodA() # all works fine
    methodB()
methodA() # throws an error
This is just a thought, that might not work at all. Or maybe there's a solution without the with statement.
 
     
     
    