[Python-Dev] Informal educator feedback on PEP 572 (was Re: 2018 Python Language Summit coverage, last part)

Chris Angelico rosuav at gmail.com
Mon Jun 25 15:42:43 EDT 2018

On Tue, Jun 26, 2018 at 5:37 AM, Terry Reedy <tjreedy at udel.edu> wrote:
> How loop variables might be isolated without a nested scope: After a
> comprehension is parsed, so that names become strings, rename the loop
> variables to something otherwise illegal.  For instance, i could become
> '<i>', just as lambda becomes '<lambda>' as the name of the resulting
> function.  Expand the comprehension as in Python 2, except for deleting the
> loop names along with the temporary result name.
> Assignment expressions within a comprehension would become assignment
> expressions within the for loop expansion and would automatically add or
> replace values in the namespace containing the comprehension.  In other
> words, I am suggesting that if we want name expressions in comprehensions to
> act as they would in Python 2, then we should consider reverting to an
> altered version of the Python 2 expansion.

So..... sublocal scopes, like in the earliest versions of PEP 572?

The wheel turns round and round, and the same spokes come up.


More information about the Python-Dev mailing list