Mega Code Archive

 
Categories / Python Tutorial / Statement
 

Generator expressions return a generator object, which in turn supports the iteration protocol to yield one piece of the result

G = (x ** 2  for x in range(4)) print G.next(  )