On 2007-07-24, treble54 <[EMAIL PROTECTED]> wrote:
> Does anyone know a way to use closures or blocks in python like
> those used in Ruby? Particularly those used in the { } braces.
Python's nameless functions are week. So it supports iterators
and generators using protocols, comprehensions and a few simple
statements, rather than promoting the use of nameless functions.
Ruby's
some_list.each do |item|
puts item
end
if I understood it correctly, In Python would be:
for item in some_list:
print item
That works for any object that supports the iterator protocol.
--
Neil Cerutti
--
http://mail.python.org/mailman/listinfo/python-list