guthrie wrote:
-- I don't get this - the only local loop variable is "e", not lst.
Yes, but the whole list comprehension gets put into a nested function, including the part that evaluates lst. (It's not strictly *necessary* to do that, but that's the way it happens to be implemented at the moment.)
It would generally be the case that a nested function would have access to its enclosing scope.
Usually, but class namespaces are a special case -- they're not considered to be enclosing scopes, even though textually they're written that way.
it certainly appears un-intuitive
It is, but it's hard to see what could be done to improve the situation without introducing worse problems. -- Greg -- http://mail.python.org/mailman/listinfo/python-list