<br><br><div class="gmail_quote">On Wed, Apr 9, 2008 at 7:44 PM, Jerry Hill &lt;<a href="mailto:malaclypse2@gmail.com">malaclypse2@gmail.com</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">On Wed, Apr 9, 2008 at 7:12 AM, Dinesh B Vadhia<br>
&lt;<a href="mailto:dineshbvadhia@hotmail.com">dineshbvadhia@hotmail.com</a>&gt; wrote:<br>
&gt; I want to replace the for loop with a List Comrehension (or whatever) to<br>
&gt; improve performance (as the data list will be &gt;10,000]. &nbsp;At each stage of<br>
&gt; the for loop I want to print the result ie.<br>
<br>
</div>List comprehensions are for building lists, not consuming them. &nbsp;If<br>
you want to do something with every element in a list, other than<br>
building a new list with it, you should be using a for loop.<br>
<div class="Ih2E3d"><br>
&gt; [print (item + &quot;\n&quot;) &nbsp;for item in data]<br>
&gt;<br>
&gt; But, this doesn&#39;t work as the inclusion of the print causes an invalid<br>
&gt; syntax error.<br>
&gt;<br>
&gt; Any thoughts?<br>
<br>
</div>Don&#39;t do this.<br>
<br>
Perhaps you could share a small piece of code that you think is too<br>
slow, and ask for advice in speeding it up? &nbsp;If you&#39;re not sure which<br>
small pieces of code are too slow, you need to profile your<br>
application to find out. &nbsp;See the documentation for python&#39;s profile<br>
module. &nbsp;If you don&#39;t have enough code written to profile, then it&#39;s<br>
probably too early to be doing these optimizations.<br>
<br>
--<br>
<font color="#888888">Jerry<br>
</font><div><div></div><div class="Wj3C7c">_______________________________________________<br>
Tutor maillist &nbsp;- &nbsp;<a href="mailto:Tutor@python.org">Tutor@python.org</a><br>
<a href="http://mail.python.org/mailman/listinfo/tutor" target="_blank">http://mail.python.org/mailman/listinfo/tutor</a><br>
</div></div></blockquote></div><br><br>if you explain the source of the list, what do you want to change in it, what destination will it take, i m sure the guys here will help a lot.<br>