On Fri, 28 May 2021 at 13:11, Steven D'Aprano <[email protected]> wrote:

> We might not even need new syntax if we could do that transformation
> using a decorator.
>
>
>     @static(var=initial)
>     def func():
>         body

The problem here is injecting the "nonlocal var" statement and
adjusting all of the references to the variable in body. I don't think
that can be done short of bytecode manipulation.
Paul
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/OSOQYJN5I5Z7II2OAQDO3FQZZCA3QJ54/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to