[Python-Dev] Changing a value in a frame (for a debugger)
Greg Ewing
greg.ewing at canterbury.ac.nz
Wed Feb 7 07:13:39 CET 2007
Fabio Zadrozny wrote:
> frame = findFrame(thread_id, frame_id)
> exec '%s=%s' % (attr, expression) in frame.f_globals, frame.f_locals
The locals of a function are actually stored in an array.
When you access them as a dict using locals(), all you
get is a dict containing a copy of their current values.
Modifying that dict doesn't affect the underlying array.
It seems that reading the f_locals of a frame does the
same thing. To modify the locals, you would need to poke
values into the original array -- but it doesn't seem
to be exposed to Python.
So it looks like you're out of luck.
--
Greg
More information about the Python-Dev
mailing list