![](https://secure.gravatar.com/avatar/047f2332cde3730f1ed661eebb0c5686.jpg?s=120&d=mm&r=g)
On Tue, Jan 19, 2016 at 12:24 PM, Serhiy Storchaka <storchaka@gmail.com> wrote:
A number of variants of more powerful syntax were proposed in [1]. In neighbour topic Scott Sanderson had pointed to the asconstants decorator in codetransformer [2] that patches the code object by substituting a references to the variable with a reference to the constant. Ryan Gonzalez provided other implementation of similar decorator [3].
May be this feature doesn't need new syntax, but just new decorator in the stdlib.
Hmm... Using a decorator would mean that you'd probably have to add quotes around the names of the variables whose values you want to capture, and it'd require hacking the bytecode. That would mean that it'd only work for CPython, and it'd not be a real part of the language. This feels like it wants to be a language-level feature, like nonlocal.
[1] http://comments.gmane.org/gmane.comp.python.ideas/37047 [2] http://permalink.gmane.org/gmane.comp.python.ideas/36958 [3] http://permalink.gmane.org/gmane.comp.python.ideas/37058
-- --Guido van Rossum (python.org/~guido)