A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/attachments/20070207/89e064ec/attachment.html below:

On 2/7/07, <b class="gmail_sendername">Greg Ewing</b> &lt;<a href="mailto:greg.ewing@canterbury.ac.nz">greg.ewing@canterbury.ac.nz</a>&gt; wrote:<div><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Fabio Zadrozny wrote:<br><br>&gt; frame = findFrame(thread_id, frame_id)<br>&gt; exec &#39;%s=%s&#39; % (attr, expression) in frame.f_globals, frame.f_locals<br><br>The locals of a function are actually stored in an array.
<br>When you access them as a dict using locals(), all you<br>get is a dict containing a copy of their current values.<br>Modifying that dict doesn&#39;t affect the underlying array.<br><br>It seems that reading the f_locals of a frame does the
<br>same thing. To modify the locals, you would need to poke<br>values into the original array -- but it doesn&#39;t seem<br>to be exposed to Python.<br><br>So it looks like you&#39;re out of luck.<br></blockquote></div><br>
Would it be ok to add a feature request for that? I initially thought it was completely read-only, but I find it strange that it affects the topmost frame correctly (so, it seems that even though I get a copy, when I alter that copy on the topmost frame it affects it correctly)... anyone has a clue why that happens?
<br><br>It seems to affect pdb too...<br><br>Consider the code:<br>if __name__ == &#39;__main__&#39;:<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; def call1():<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v_on_frame1 = 10<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &#39;v_on_frame1&#39;, v_on_frame1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
<br>&nbsp;&nbsp;&nbsp; def call0():<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; import pdb;pdb.set_trace()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; v_on_frame0 = 10<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; call1()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &#39;v_on_frame0&#39;, v_on_frame0<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; call0()<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; <br>#when modifying in the current frame
<br>&gt; x:\scbr15\source\python\tests_base\empty_test.py(9)call0()<br>-&gt; v_on_frame0 = 10<br>(Pdb) n<br>&gt; x:\scbr15\source\python\tests_base\empty_test.py(10)call0()<br>-&gt; call1()<br>(Pdb) v_on_frame0 = 40<br>(Pdb) c
<br>v_on_frame1 10<br>v_on_frame0 40<br><br><br><br>#when modifying an upper frame it does not work<br>&gt; x:\scbr15\source\python\tests_base\empty_test.py(9)call0()<br>-&gt; v_on_frame0 = 10<br>(Pdb) n<br>&gt; x:\scbr15\source\python\tests_base\empty_test.py(10)call0()
<br>-&gt; call1()<br>(Pdb) s<br>--Call--<br>&gt; x:\scbr15\source\python\tests_base\empty_test.py(3)call1()<br>-&gt; def call1():<br>(Pdb) n<br>&gt; x:\scbr15\source\python\tests_base\empty_test.py(4)call1()<br>-&gt; v_on_frame1 = 10
<br>(Pdb) u<br>&gt; x:\scbr15\source\python\tests_base\empty_test.py(10)call0()<br>-&gt; call1()<br>(Pdb) v_on_frame0 = 40<br>(Pdb) d<br>&gt; x:\scbr15\source\python\tests_base\empty_test.py(4)call1()<br>-&gt; v_on_frame1 = 10
<br>(Pdb) c<br>v_on_frame1 10<br>v_on_frame0 10<br><br><br>

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4