You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
215 B
15 lines
215 B
11 years ago
|
def gen():
|
||
|
print("sent:", (yield 1))
|
||
|
yield 2
|
||
|
|
||
|
def gen2():
|
||
|
print((yield from gen()))
|
||
|
|
||
|
g = gen2()
|
||
|
next(g)
|
||
|
print("yielded:", g.send("val"))
|
||
|
try:
|
||
|
next(g)
|
||
|
except StopIteration:
|
||
|
print("StopIteration")
|