On 6/5/06, <b class="gmail_sendername">Peter Jessop</b> &lt;<a href="mailto:pjlists@gmail.com">pjlists@gmail.com</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;">
Thanks Andre<br><br>I realise now I did not make it too clear.<br>Basically the variable names are predictable but the values aren't.</blockquote><div><br>I assumed that.&nbsp; I just recreated the list as you gave it because it was easy :-)
<br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Maybe I should have expressed it like this<br><br>f0_n = &quot;arbitrayValue&quot;
<br>f0_v =&quot;another valule&quot;<br>f1_n=&quot;something else&quot;<br>f1_v=&quot;etc..&quot;<br>...<br><br>f100_n = &quot;another value&quot;<br>f100_v = &quot;nexvalue&quot;<br><br>I then wish to pass the list of 2ples as an argument to a function and
<br>thus I need the variable themselves and not the string values.</blockquote><div><br>Ok, the approach I gave you would produce instead:<br><br>data = [ (&quot;arbitraryValue&quot;, &quot;another valule&quot;), (&quot;something else&quot;, .... ]
<br><br>Why couldn't you pass this to your function? <br><br>Ok, here's another experiment...<br><br>1. I will first generate a whole bunch of arbitrary numerical values:<br>import random<br>for i in range(101):<br>&nbsp;&nbsp;&nbsp; print 'f%d_n = %d'%(i, 
random.randint(0, 100))<br>&nbsp;&nbsp;&nbsp; print 'f%d_v = %d'%(i, random.randint(0, 100))<br>===<br>f0_n = 40<br>f0_v = 28<br>f1_n = 49<br>f1_v = 5<br>...<br>====================<br>2. Next, I will use the approach I gave you before, but with these values, and I will do it with a one-liner:
<br>data = '[' + ','.join([&quot;(f%d_n, f%d_v)&quot;%(i, i) for i in range(101)]) + ']'<br><br>big_list = eval(data)<br><br>3. Next, I will define a function that works on these values<br><br>def find_special(data):<br>&nbsp;&nbsp;&nbsp; for item in data:
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if item[0] &lt; 10:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print item[1], <br><br>find_special(big_list)<br>=========<br>The result in my case turns out to be:<br>49 50 57 96 98 23 69 16 4<br>====================<br>Of course this result on its own is meaningless :-)
<br><br>Nonetheless, does this help?&nbsp; Or do you really, absolutely need to pass the named variables, not their values?<br><br>André<br><br><br><br><br></div><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
_______________________________________________<br>Tutor maillist&nbsp;&nbsp;-&nbsp;&nbsp;<a href="mailto:Tutor@python.org">Tutor@python.org</a><br><a href="http://mail.python.org/mailman/listinfo/tutor">http://mail.python.org/mailman/listinfo/tutor
</a><br></blockquote></div><br>