On Sun, Jun 24, 2018 at 11:50 AM Steven D'Aprano <st...@pearwood.info> wrote:
> [Guido] > > [...] IIRC (b) originated with Tim. > > I'm not sure who came up with the idea first, but as I remember it, the > first mention of this came in a separate thread on Python-Ideas: > > https://mail.python.org/pipermail/python-ideas/2018-April/049631.html > > so possibly I'm to blame :-) > Actually that post sounds like the OP of that thread (Peter O'Connor) is to blame -- he proposed a similar thing using `=` for the assignment and custom syntax (`from <value>`) to specify the initial value, and it looks like that inspired you. > > But his essay on the topic, included as Appendix A ( > > > https://www.python.org/dev/peps/pep-0572/#appendix-a-tim-peters-s-findings > ) > > does not even mention comprehensions. However, he did post his motivation > > for (b) on python-ideas, IIRC a bit before PyCon; and the main text of > the > > PEP gives a strong motivation ( > > https://www.python.org/dev/peps/pep-0572/#scope-of-the-target). > > Nevertheless, maybe we should compromise and drop (b)? > > I will have more to say about the whole "comprehensions are their own > scope" issue later. But I'd like to see Nick's proposed PEP, or at least > a draft of it, before making any final decisions. > Agreed, though I assume it's just `given` again. > If it came down to it, I'd be happy with the ability to declare an > assignment target nonlocal in the comprehension if that's what it takes. > What do you think of this syntax? > > [global|nonlocal] simple_target := expression > > Inside a comprehension, without a declaration, the target would be > sublocal (comprehension scope); that should make Nick happier :-) > It's more special syntax. Just taking part (a) of PEP 572 would make most people happy enough. -- --Guido van Rossum (python.org/~guido)
_______________________________________________ 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