On Fri, Feb 23, 2018 at 1:42 PM Kyle Lahnakoski <klahnako...@mozilla.com> wrote:
> > > On 2018-02-23 12:44, Neil Girdhar wrote: > > On Fri, Feb 23, 2018 at 12:35 PM Kyle Lahnakoski <klahnako...@mozilla.com> > wrote: > >> >> > [ >> > (w, w**2) >> > for x in (1, 2, 3, 4) >> > let y = x+1 >> > for a in range(y) >> > let z = a+1 >> > if z > 2 >> > for b in range(z) >> > let w = z+1 >> > ] >> >> which is a short form for: >> >> > def stuff(): >> > for x in (1, 2, 3, 4): >> > y = x+1 >> > for a in range(y): >> > z = a+1 >> > if z > 2: >> > for b in range(z): >> > w = z+1 >> > yield (w, w**2) >> > >> > list(stuff()) >> > > Is it that much shorter that it's worth giving up the benefit of > indentation? > >> >> > 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. > 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. ( https://google.github.io/styleguide/pyguide.html?showone=List_Comprehensions#List_Comprehensions ) 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 ( > https://github.com/pythonql/pythonql). > > -- > > --- > You received this message because you are subscribed to a topic in the > Google Groups "python-ideas" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/python-ideas/KwZtO4rpAGE/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > python-ideas+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > _______________________________________________ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ > > -- > > --- > You received this message because you are subscribed to a topic in the > Google Groups "python-ideas" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/python-ideas/KwZtO4rpAGE/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > python-ideas+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. >
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/