PEP 572: Statement-Local Name Bindings, take three!

I am not sure if this is valid, but perhaps this is an alternative syntax which might be simpler: ``name! expr`` So for example, instead of: stuff = [[(f(x) as y), x/y] for x in range(5)] stuff = [[y! f(x), x/y] for x in range(5)] As far as I can tell there would be no conflicts with the current uses of "!". One potential source of ambiguity would be in: x = y! a + b # should y be a or (a + b)? I think this is solved by requiring the target expression to be non-greedy. If you want a larger named expression, you can always use parenthesis. i.e. ``x = y! (z + z)`` I feel brevity and minimised punctuation are important for the adoption of statement-locals, and personally I feel it reads well. I also happen to prefer the name preceding the expression, though I suspect this is quite subjective. Also, apologies if I have grossly misunderstood something. Cammil
participants (1)
-
Cammil Taank