[Python-ideas] Language proposal: variable assignment in functional context

Lele Gaifax lele at metapensiero.it
Wed Jun 21 06:09:40 EDT 2017


Brice PARENT <contact at brice.xyz> writes:

> Examples:
>
> with b = a + 1:
>     y = b + 2

I don't think that could work, because the with "arguments" should be
expressions, not statements. However, IIRC someone already suggested the
alternative

with a+1 as b:
    y = b + 2

but that clashes with the ordinary "context manager" syntax.

It's a pity "exec" is now a plain function, instead of a keyword as it was in
Py2, as that could allow

exec:
    y = b + 2
with: # or even "in:"
    b = a + 1

ciao, lele.
-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
lele at metapensiero.it  |                 -- Fortunato Depero, 1929.



More information about the Python-ideas mailing list