On Feb 22, 2018, at 11:04, Serhiy Storchaka <storch...@gmail.com> wrote: > > Stephan Houben proposed an idiom which looks similar to new hypothetic syntax: > > result = [y + g(y) for x in range(10) for y in [f(x)]] > > `for y in [expr]` in a comprehension means just assigning expr to y. I never > seen this idiom before, but it can be a good replacement for a hypothetic > syntax for assignment in comprehensions. It changes the original > comprehension less than other approaches, just adds yet one element in a > sequence of for-s and if-s. I think that after using it more widely it will > become pretty idiomatic.
My questions are 1) will this become idiomatic enough to be able to understand at a glance what is going on, rather than having to pause to reason about what that 1-element list-like syntax actually means, and 2) will this encourage even more complicated comprehensions that are less readable than just expanding the code into a for-loop? for-loops-are-not-evil-ly y’rs, -Barry
signature.asc
Description: Message signed with OpenPGP
_______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com