Inspect find class in stack

166 Views Asked by At

I need to get the class (not just the name, the real class ref) from an inspect stack return.

Say i have this:

def methodthatneedcls():
    cls = ### code here


class excls:
    def somemethod():
        methodthatneedcls()
         
        something = "is happening here"
        return something

if i go back with inspect.stack() i want to get the class reference of the previous entry in the stack, in this case the excls reference. I looked into to the return of inspect.stack() but i didnt find anything useful there. If there is an alternative method that allows me to get the class reference of the previous stack it is also welcomened

0

There are 0 best solutions below