4 ms·
there's a secret hack to get your `f_locals` changes to propogate back exec( code_fragment, frame.f_globals, frame.
by rtpg 9y ago
there's a secret hack to get your `f_locals` changes to propogate back
exec(
code_fragment,
frame.f_globals,
frame.f_locals
)
# update locals
ctypes.pythonapi.PyFrame_LocalsToFast(ctypes.py_object(frame), ctypes.c_int(0))
This sets the values back into the right place on the frame you were operating on.
https://pydev.blogspot.jp/2014/02/changing-locals-of-frame-frameflocals.html https://pydev.blogspot.jp/2014/02/changing-locals-of-frame-f...