<html>
<body>
At Thursday 7/4/2005 10:53, * William wrote:<br><br>
Please stay in the list - and even move to the Python-list as those
topics are not specific to Windows.<br><br>
<blockquote type=cite class=cite cite="">Exactly what I want to do -- for
the enquiry about &quot;what&quot; I want to do, it is best to use as an
example.<br>

<dl>
<dd><font face="Courier New, Courier" size=2>#4<br>

<dd>b = 2<br>

<dd>print &quot;Before:&quot;<br>

<dd>print &quot;&nbsp;&nbsp; a = %s&quot; % str( a )<br>

<dd>print &quot;&nbsp;&nbsp; b = %s&quot; % str( b )# <br>

<dd>codeLine = 'a = b + 6'<br>

<dd>exec codeLine&nbsp; in globals(), locals()<br>

<dd>#<br>

<dd>print &quot;After:&quot;<br>

<dd>print &quot;&nbsp;&nbsp; a = %s&quot;% str( a )<br>

<dd>print &quot;&nbsp;&nbsp; b = %s&quot; % str( b )<br>
</font><br>

</dl>... of course the notion, is a little more elaborate though still in
its infancy.&nbsp; I am thinking it will be a basic verification tool or
even an aid for debugging.&nbsp; By chopping up the line, I can print the
value of all the symbols in the codeLine.&nbsp; The 'trick' is going to
be Not calling functions twice (in case there is a side-effect).&nbsp;
</blockquote><br>
So you are going to write your own debugger? I'd try the existing ones
first :)<br><br>
It's hard to recognize automatically the relevant symbols, even using the
tokenize/token/parser modules.<br>
Unles you restrict yourself to very simple expressions with no objects,
no attribute selection, no subscripting...<br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>
a[round(math.sin(2*math.pi*obj.current_angle/180.0+obj.phase))]*x+config['offset']<br>
There is a lot of names there: a,round,math,sin,pi,obj... Some just make
sense in the context of another (by example, there is no phase variable,
it's an attribute of obj). Maybe current_angle is a property and getting
its value actually means invoking a function wich reads a
sensor...<br><br>
<blockquote type=cite class=cite cite="">&nbsp;For example, I'd like a
way to get the symbol name for variable a above.&nbsp; Is there a
function like &quot;nameOF( a )&quot;?</blockquote><br>
Maybe a Python hacker guru could say something, but AFAIK, once you get
inside the function nameOF( a ), there is no way to tell where its
argument came from. In the following example, I think there is no way to
distinguish inside f if it was called with a or b as an argument, since
both are simply names pointing to the same object:<br><br>
&gt;&gt;&gt; def f(x):<br>
...&nbsp;&nbsp; print x, id(x)<br>
...<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; a = [1,2,3]<br>
&gt;&gt;&gt; b = a<br>
&gt;&gt;&gt; a<br>
[1, 2, 3]<br>
&gt;&gt;&gt; b<br>
[1, 2, 3]<br>
&gt;&gt;&gt; id(a)<br>
6999440<br>
&gt;&gt;&gt; id(b)<br>
6999440<br>
&gt;&gt;&gt; f(a)<br>
[1, 2, 3] 6999440<br>
&gt;&gt;&gt; f(b)<br>
[1, 2, 3] 6999440<br>
&gt;&gt;&gt;<br><br>
<x-sigsep><p></x-sigsep>
Gabriel Genellina<br>
Softlab SRL</body>
</html>