'Return the object corresponding to expression evaluated
in a namespace spanning sys.modules and __main.dict__.'

def get_entity(self, expression):

    if expression:
        namespace = sys.modules.copy()
        namespace.update(__main__.__dict__)
        try:
            return eval(expression, namespace)
        except BaseException:
            return None
