Saturday, July 18, 2009

trac代码阅读2 - yield expressions

例:
def test(value = None):
    i = value or 0
    while i < 100:
        yield i
        i += 1
=============>>>>>
>>> s.next()
0
>>> s.next()
1
>>> s.next()
2
>>> s.next()
3


由外部逻辑控制此generator function的执行,  we called it: Semi-Coroutine

No comments: