<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Aug 10, 2017 at 1:53 PM, Spencer Brown <span dir="ltr"><<a href="mailto:spencerb21@live.com" target="_blank">spencerb21@live.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="auto">
<div>
<div id="m_-1452361413201393627AppleMailSignature"><span style="background-color:rgba(255,255,255,0)">The logical solution to me is to allow any order of while and if, and follow the same 'rule' as multiple for loops - just nest/test those in that order. </span></div></div></div></blockquote><div><br></div><div>Actually, I think it would be better to only allow one order, and have the "while" always teeted first -- which may mean it should be placed first for clarity.</div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div><div id="m_-1452361413201393627AppleMailSignature"><span style="background-color:rgba(255,255,255,0)">Then you can have whatever
priority you need. One question though is how this should handle multiple loops - break all of them, or just the current one?</span></div></div></div></blockquote><div><br></div><div>just the current one, just like a "break", or for that matter, a nested while...</div><div><br></div><div>-CHB</div><div><br></div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div><span class="HOEnZb"><font color="#888888">
<div id="m_-1452361413201393627AppleMailSignature"><span style="background-color:rgba(255,255,255,0)">- Spencer Brown</span></div>
</font></span></div><div><div class="h5">
<div><br>
On 11 Aug 2017, at 6:27 am, Chris Barker <<a href="mailto:chris.barker@noaa.gov" target="_blank">chris.barker@noaa.gov</a>> wrote:<br>
<br>
</div>
<blockquote type="cite">
<div>
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">On Thu, Aug 10, 2017 at 8:39 AM, Paul Moore <span dir="ltr">
<<a href="mailto:p.f.moore@gmail.com" target="_blank">p.f.moore@gmail.com</a>></span> wrote:<br>
<div> </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Also, there's a potential issue<br>
here - consider<br>
<br>
[expr for var in even_numbers() if is_odd(var) while var < 100]<br>
<br>
This is an infinite loop, even though it has a finite termination<br>
condition (var < 100), because we only test the termination condition<br>
if var is odd, which it never will be.<br>
</blockquote>
<div><br>
</div>
<div>why is the termination only tested if teh if clause is True? Could then not be processed in parallel? or the while first....</div>
<div><br>
</div>
<div>so maybe better to do:</div>
<div><br>
</div>
<div>[expr for var in even_numbers() while var < 100 if is_odd(var)]</div>
<div><br>
</div>
<div>Maybe it's just me, but I would certainly expect the while to have precedence.</div>
<div><br>
</div>
<div>I guess I think of it like this:</div>
<div><br>
</div>
<div>"if" is providing a filtering mechanism</div>
<div><br>
</div>
<div>"while" is providing a termination mechanism</div>
<div><br>
</div>
<div> -- is there a use case anyone can think of when they would want the while to be applied to the list AFTER filtering?</div>
<div><br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Obviously, this is a contrived example. And certainly "don't do that,<br>
then" is a valid response. But my instinct is that people are going to<br>
get this wrong - *especially* in a maintenance environment.</blockquote>
<div><br>
</div>
<div>sure, but would there be an issue if teh while were given precedence?</div>
<div><br>
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Overall, I agree with Steven's point. It seems pretty obvious what the<br>
intention is, and while it's probably possible to construct examples<br>
that are somewhat unclear,<br>
<br>
1. The mechanical rule gives an explicit meaning<br>
2. People shouldn't be writing such complex comprehensions, so if the<br>
rule doesn't give what they expect, they can always rewrite the code<br>
with an explicit (and clearer) loop.<br>
</blockquote>
<div><br>
</div>
<div>me too -- a direct translation to a for loop isn't necessary to understand how it works.</div>
<div> </div>
<div>-CHB</div>
</div>
<div><br>
</div>
<div class="gmail_extra"><br>
</div>
-- <br>
<div class="m_-1452361413201393627gmail_signature"><br>
Christopher Barker, Ph.D.<br>
Oceanographer<br>
<br>
Emergency Response Division<br>
NOAA/NOS/OR&R <a href="tel:(206)%20526-6959" value="+12065266959" target="_blank">(206) 526-6959</a> voice<br>
7600 Sand Point Way NE <a href="tel:(206)%20526-6329" value="+12065266329" target="_blank">(206) 526-6329</a> fax<br>
Seattle, WA 98115 <a href="tel:(206)%20526-6317" value="+12065266317" target="_blank">(206) 526-6317</a> main reception<br>
<br>
<a href="mailto:Chris.Barker@noaa.gov" target="_blank">Chris.Barker@noaa.gov</a></div>
</div>
</div>
</div>
</blockquote>
</div></div><blockquote type="cite">
<div><span>______________________________<wbr>_________________</span><span class=""><br>
<span>Python-ideas mailing list</span><br>
<span><a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a></span><br>
<span><a href="https://mail.python.org/mailman/listinfo/python-ideas" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-ideas</a></span><br>
<span>Code of Conduct: <a href="http://python.org/psf/codeofconduct/" target="_blank">http://python.org/psf/<wbr>codeofconduct/</a></span><br>
</span></div>
</blockquote>
</div>
<br>______________________________<wbr>_________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/<wbr>mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/<wbr>codeofconduct/</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="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></div>