<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Fri, Feb 23, 2018 at 1:42 PM Kyle Lahnakoski <<a href="mailto:klahnakoski@mozilla.com">klahnakoski@mozilla.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF">
<p><br>
</p>
<br>
<div class="m_-5530858871065944147moz-cite-prefix">On 2018-02-23 12:44, Neil Girdhar
wrote:<br>
</div>
</div><div text="#000000" bgcolor="#FFFFFF"><blockquote type="cite"><div dir="ltr"><div class="gmail_quote">
<div dir="ltr">On Fri, Feb 23, 2018 at 12:35 PM Kyle
Lahnakoski <<a href="mailto:klahnakoski@mozilla.com" target="_blank">klahnakoski@mozilla.com</a>>
wrote:<br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
> [<br>
> (w, w**2)<br>
> for x in (1, 2, 3, 4)<br>
> let y = x+1<br>
> for a in range(y)<br>
> let z = a+1<br>
> if z > 2<br>
> for b in range(z)<br>
> let w = z+1<br>
> ]<br>
<br>
which is a short form for:<br>
<br>
> def stuff():<br>
> for x in (1, 2, 3, 4):<br>
> y = x+1<br>
> for a in range(y):<br>
> z = a+1<br>
> if z > 2:<br>
> for b in range(z):<br>
> w = z+1<br>
> yield (w, w**2)<br>
><br>
> list(stuff())<br>
</blockquote>
<div><br>
</div>
<div>Is it that much shorter that it's worth giving up the
benefit of indentation? </div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
</blockquote>
</div></div></blockquote></div><div text="#000000" bgcolor="#FFFFFF"><blockquote type="cite"><div dir="ltr"><div class="gmail_quote"></div>
</div>
</blockquote>
<br>
Saving the indentation? Oh yes, for sure! This code reads like a
story, the indentation is superfluous to that story. Should we add
it to Python? I don't know; I quick scan through my own code, and I
do not see much opportunity for list comprehensions of this
complexity. </div></blockquote><div><br></div><div>That's a good thing that you are not writing code like this. I don't agree that the indentation is "superfluous". It makes the code easy to read. Anyway, Google's Python style guide also agrees that very long comprehensions like that are not worth it. (<a href="https://google.github.io/styleguide/pyguide.html?showone=List_Comprehensions#List_Comprehensions">https://google.github.io/styleguide/pyguide.html?showone=List_Comprehensions#List_Comprehensions</a>)</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF"> Either my data structures are not that complicated, or
I have try/except blocks inside a loop, or I am using a real query
language (like SQL). pythonql seems to solve all these problems
well enough (<a class="m_-5530858871065944147moz-txt-link-freetext" href="https://github.com/pythonql/pythonql" target="_blank">https://github.com/pythonql/pythonql</a>). </div></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div text="#000000" bgcolor="#FFFFFF">
<br>
</div>
<p></p>
-- <br>
<br>
--- <br>
You received this message because you are subscribed to a topic in the Google Groups "python-ideas" group.<br>
To unsubscribe from this topic, visit <a href="https://groups.google.com/d/topic/python-ideas/KwZtO4rpAGE/unsubscribe" target="_blank">https://groups.google.com/d/topic/python-ideas/KwZtO4rpAGE/unsubscribe</a>.<br>
To unsubscribe from this group and all its topics, send an email to <a href="mailto:python-ideas+unsubscribe@googlegroups.com" target="_blank">python-ideas+unsubscribe@googlegroups.com</a>.<br>
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank">https://groups.google.com/d/optout</a>.<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>
<br>
--<br>
<br>
---<br>
You received this message because you are subscribed to a topic in the Google Groups "python-ideas" group.<br>
To unsubscribe from this topic, visit <a href="https://groups.google.com/d/topic/python-ideas/KwZtO4rpAGE/unsubscribe" rel="noreferrer" target="_blank">https://groups.google.com/d/topic/python-ideas/KwZtO4rpAGE/unsubscribe</a>.<br>
To unsubscribe from this group and all its topics, send an email to <a href="mailto:python-ideas%2Bunsubscribe@googlegroups.com" target="_blank">python-ideas+unsubscribe@googlegroups.com</a>.<br>
For more options, visit <a href="https://groups.google.com/d/optout" rel="noreferrer" target="_blank">https://groups.google.com/d/optout</a>.<br>
</blockquote></div></div>