On Fri, Jul 26, 2002 at 02:58:51AM +0900, John Knight wrote:
> - Ruby has an extremely elegant way to pass code blocks to a method,
>   and uses it neatly for iterating over a collection:
>   list.each do |currentListItem|  print currentListItem end

Python has this as well.  While Ruby calls each() an iterator, Python
calls it a generator.  E.g.:

  from __future__ import generators
  def fibonacci(a=1, b=1): 
    while 1: 
      yield a 
      a, b = b, a+b
  t = fibonacci() # t is an iterator!
  for i in range(10): print t.next()

Python has only gotten this recently, and many people suspect that this
is due to the influence of its long-lost cousin.

Paul