On 6/25/2018 8:25 AM, Paul Moore wrote: > On 25 June 2018 at 12:44, Nick Coghlan <ncoghlan at 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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4