En Mon, 05 Feb 2007 16:47:43 -0300, metaperl <[EMAIL PROTECTED]> escribió:


> For this program:
>
> def reverse(data):
>     for index in range(len(data)-1, -1, -1):
>         yield data[index]
>
> r = reverse("golf")
>
> for char in r:
>     print char
>
>
> I'm wondering if the line:
>
> r = reverse("golf")
>
> "demands" the contents of the function reverse() all at once and if I
> must write
>
> for char in reverse("golf"):
>     print char
>
> if I want the results streamed instead of generated complely.

reverse is a generator; it executes one step at a time. That's the whole  
point of generators.

-- 
Gabriel Genellina

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

Reply via email to