frame = sys._getframe().f_back is the previous stack frame. Is there any way to execute (with exec or eval) frame.f_code beginning from frame.f_lasti or frame.f_lineno? I am trying to spawn a thread that is initialized with the code and state of the previous stack frame. S.M.