[Python-ideas] Local scope for statement blocks
Andrew Barnert
abarnert at yahoo.com
Tue Mar 4 07:51:17 CET 2014
On Mar 3, 2014, at 19:39, Brian Nguyen <musicdenotation at gmail.com> wrote:
> do:
> nonlocal x
> k = init
> for i in list:
> k = f(i,k)
> n = f2(n,k)
You want _every_ compound statement to be a scope, or you just want to add a new one, a "do" statement, and only that new one is a scope?
If the latter, i believe you can do this pretty easily with a MacroPy macro (which will expand to a def and a function call). It might be worth playing with that to get some real-life examples of using it.
More information about the Python-ideas
mailing list