How do I get the exact class variable which is (in current scope) available under a given name? I want to write a function like this:

```py
from my_module import ClassA # A subclass of my_other_module.BenevolentClass
from my_other_module import my_function
a = 'ClassA'
cls_var = my_function(a)
o = cls_var()

```

So that I could supply any string to my\_function and so long as that string is available in the caller's namespace as a class name, it would produce the correct class much like if I copypasted the string directly to the code. The reason is that I need to supply class names to a complex object creation routine, but avoid `eval` when possible. My current implementation is like this:

```py
def my_function(name):
    if name in globals():
        c = globals()[name]
        # Actually a complex class whitelist
        if issubclass(c, BenevolentClass):
            return c
        else:
            raise ValueError(f'Potentially malicious class {name}')

```

But that apparently produces globals() from my\_other\_module, which is not what I want. I want all classes that are available at the exact line of code where `my_function` is called (which may be inside completely different module which is called from yet another one).