"Jerry Hill" <[EMAIL PROTECTED]> writes:

> On Fri, Feb 29, 2008 at 10:01 PM, Ken Pu <[EMAIL PROTECTED]> wrote:
>>  Is there a way for me keep the iterating variable in list
>>  comprehension local to the list comprehension?
>
> Kind of.  You can use a generator expression instead of a list
> comprehension, and those don't leak their internal variables into the
> enclosing scope:

Whoa, that's cool. I didn't even think to try that, just assuming it
would do the same.

Though now that I think about it, I don't see how it possibly could,
since it just evaluates to an object that you could pass around, and
return, using it the same way elsewhere.

-- 
Micah J. Cowan
Programmer, musician, typesetting enthusiast, gamer...
http://micah.cowan.name/
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to