<div dir="ltr">however, he did bring up a python-idea worthy general topic:<div><br></div><div>Sometimes you want to iterate without doing anything with the results of the iteration.</div><div><br></div><div>So the obvious is his example -- iterate N times:</div><div><br></div><div>for i in range(N):</div><div>    do_something</div><div><br></div><div>but you may need to look into the code (probably more than one line) to see if i is used for anything.</div><div><br></div><div>I know there was talk way back about making integers iterable, so you could do:</div><div><br></div><div>for i in 32:</div><div>   do something.</div><div><br></div><div>which would be slightly cleaner, but still has an extra i in there, and this was soundly rejected anyway (for good  reason). IN fact, Python's "for" is not really about iterating N times, it's about iteraton over a sequence of objects. Ans I for one find:</div><div><br></div><div>for _ in range(N):</div><div><br></div><div>To be just fine -- really very little noise or performance overhead or anything else.</div><div><br></div><div>However, I've found myself wanting a "make nothing comprehension". For some reason, I find myself frequently following a pattern where I want to call the same method on all the objects in a sequence:</div><div><br></div><div>for obj in a_sequence:</div><div>    obj.a_method()</div><div><br></div><div>but I like the compactness of comprehensions, so I do:</div><div><br></div><div>[obj.a_method() for obj in a_sequence]</div><div><br></div><div>but then this creates a list of the result from that method call. Which I don't want, so I don't assign the results to anything, and it just goes away.</div><div><br></div><div>But somehow it bugs me that I'm creating this (maybe big) ol' list full of junk, just to have it deleted.</div><div><br></div><div>Anyone else think this is a use-case worth supporting better? Or should I jstu get over it -- it's really not that expensive to create a list, after all.</div><div><br></div><div>-Chris</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 10, 2015 at 12:07 AM, Terry Reedy <span dir="ltr"><<a href="mailto:tjreedy@udel.edu" target="_blank">tjreedy@udel.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 9/9/2015 1:10 PM, Stephan Sahm wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I found a BUG in the standard while statement, which appears both in<br>
python 2.7 and python 3.4 on my system.<br>
</blockquote>
<br></span>
No you did not, but aside from that: python-ideas is for ideas about future versions of python, not for bug reports, valid or otherwise.  You should have sent this to python-list, which is a place to report possible bugs.<span class="HOEnZb"><font color="#888888"><br>
<br>
-- <br>
Terry Jan Reedy</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><br>Christopher Barker, Ph.D.<br>Oceanographer<br><br>Emergency Response Division<br>NOAA/NOS/OR&R            (206) 526-6959   voice<br>7600 Sand Point Way NE   (206) 526-6329   fax<br>Seattle, WA  98115       (206) 526-6317   main reception<br><br><a href="mailto:Chris.Barker@noaa.gov" target="_blank">Chris.Barker@noaa.gov</a></div>
</div>