On Thu, 16 Feb 2006 15:18:29 +0000, John Salerno wrote:

> What's an example of a local scope without 
> having a function definition? Loops and if statements, perhaps?

List comprehensions: [2*x+1 for x in range(50)]

Lambdas: map(lambda y: y-2, [1,2,4,8,16,32])

At the moment the x in list comprehensions are exported to the rest of the
local scope, but that (mis)feature is officially going to be removed in
future versions of Python.


-- 
Steven.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to