Getting pdb-style caller information in python
Question: Let's say I have the following method (in a class or a module, I don't think
it matters):

    
    
    def someMethod():
        pass
    

I'd like to access the caller's state at the time this method is called.

`traceback.extract_stack` just gives me some strings about the call stack.

I'd like something like `pdb` in which I can set a breakpoint in
`someMethod()` and then type 'u' to go up the call stack and then examine the
state of the system then.


Answer: I figured it out:

    
    
    import inspect
    
    def callMe():
        tag = ''
        frame = inspect.currentframe()
        try:
            tag = frame.f_back.f_locals['self']._tag
        finally:
            del frame
    
        return tag
    

