kevin parks wrote:
called, and what it is an example of. I guess there are generators and
iterators now and it seems this might be an example of one of those new
This is a generator expression. It is like a list comprehension (you
know about those right?) except it doesn't create the list it just
returns each item on demand. You could think of a list as a list
constructed using a generator expression.
def roundrobin(*iterables):
"roundrobin('ABC', 'D', 'EF') --> A D E B F C"
# Recipe credited to George Sakkis
pending = len(iterables)
nexts = cycle(iter(it).next for it in iterables)
note this is storing the next methods not the results of them.
while pending:
try:
for next in nexts:
yield next()
So the yield calls the stored method and returns the result.
HTH,
Alan G.
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor