On 6/25/2018 8:25 AM, Paul Moore wrote:
On 25 June 2018 at 12:44, Nick Coghlan <ncogh...@gmail.com> wrote:
Unfortunately, I think the key rationale for (b) is that if you
*don't* do something along those lines, then there's a different
strange scoping discrepancy that arises between the non-comprehension
forms of container displays and the comprehension forms:

I've been mostly ignoring this proposal for a while now, so I'm going
to respond here in the context of someone with a bit of an idea of the
underlying complexities, but otherwise coming at it as a new proposal.


     (NAME := EXPR,) # Binds a local
     tuple(NAME := EXPR for __ in range(1)) # Doesn't bind a local

Of course not, in local scopes where is it not executed. But it would, in the nested function where the assignment *is* executed. Ditto for all of the following.

     [NAME := EXPR] # Binds a local
     [NAME := EXPR for __ in range(1)] # Doesn't bind a local
     list(NAME := EXPR for __ in range(1)) # Doesn't bind a local

     {NAME := EXPR} # Binds a local
     {NAME := EXPR for __ in range(1)} # Doesn't bind a local
     set(NAME := EXPR for __ in range(1)) # Doesn't bind a local

     {NAME := EXPR : EXPR2} # Binds a local
     {NAME := EXPR : EXPR2 for __ in range(1)} # Doesn't bind a local
     set((NAME := EXPR, EXPR2) for __ in range(1)) # Doesn't bind a local

None of those "discrepancies" bother me in the slightest,

Me neither. I pretty much agree with the rest of what Paul said. If we don't want comprehensions to execute in a nested scope, then we should not create one. See my response to Guido for a possible alternative.

--
Terry Jan Reedy

_______________________________________________
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

Reply via email to