On 28.06.2018 2:31, Greg Ewing wrote:
Steven D'Aprano wrote:
The *very first* motivating example for this proposal came from a comprehension.
I think it is both unfortunate and inevitable that the discussion bogged down in comprehension-hell.
I think the unfortunateness started when we crossed over from talking about binding a temporary name for use *within* a comprehension or expression, to binding a name for use *outside* the comprehension or expression where it's bound.
I've shown in email@example.com (27 Jun 2018 17:07:24 +0300) that assignment expressions are fine in most use cases without any changes to scoping whatsoever.
So, as Guido suggested in CAP7+vJ+xBAT4ZvAo4B7qSqxnnpj8jJ1VZ-Le7EwT8=n-UTjE3Q@mail.gmail.com (26 Jun 2018 19:36:14 -0700), the scoping matter can be split into a separate PEP and discussion.
As long as it's for internal use, whether it's in a comprehension or not isn't an issue.
Tim Peters has also given a couple of good examples of mathematical code that would benefit strongly from this feature.
Going back a few months now, they were the examples that tipped me over
Well, I remain profoundly unconvinced that writing comprehensions with side effects is ever a good idea, and Tim's examples did nothing to change that.