On Fri, 28 May 2021 at 13:11, Steven D'Aprano <st...@pearwood.info> 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 -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/OSOQYJN5I5Z7II2OAQDO3FQZZCA3QJ54/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to