On Fri, 28 May 2021 at 13:11, Steven D'Aprano firstname.lastname@example.org 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