Don't repeat the inspect.stack code, refactor it into a get_local_namespace function