[Python-ideas] Fwd: quantifications, and tuple patterns (original) (raw)

Paul Moore p.f.moore at gmail.com
Tue Jan 17 14:34:21 CET 2012


On 17 January 2012 11:16, Nick Coghlan <ncoghlan at gmail.com> wrote:

Assignments as expressions aren't all that easy to use in the "some" case that started the thread, and the reason is the same as the reason iteration variables in comprehensions don't leak into the surrounding scope any more: generator expressions and comprehensions create their own scope, separate from that of the containing function.

Ah. I tested the idea by setting an attribute of an existing object, which does work (but is ugly). I'd forgotten that scoping comes into the picture when you switch to assignment.

I'll refrain from proposing "nonlocal x := var"... :-)

Paul.



More information about the Python-ideas mailing list