"flushing"/demanding generator contents - implications for injection of control
Gabriel Genellina
gagsl-py at yahoo.com.ar
Mon Feb 5 19:47:01 EST 2007
More information about the Python-list mailing list
Mon Feb 5 19:47:01 EST 2007
- Previous message (by thread): Why?
- Next message (by thread): "flushing"/demanding generator contents - implications for injection of control
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
En Mon, 05 Feb 2007 16:47:43 -0300, metaperl <metaperl at gmail.com> 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
- Previous message (by thread): Why?
- Next message (by thread): "flushing"/demanding generator contents - implications for injection of control
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list