iterator send
This commit is contained in:
parent
173498f32b
commit
b01dea087f
17
python-temel/iterator.send.py
Normal file
17
python-temel/iterator.send.py
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
def foo():
|
||||||
|
x = yield
|
||||||
|
print(x)
|
||||||
|
x = yield
|
||||||
|
print(x)
|
||||||
|
x = yield
|
||||||
|
print(x)
|
||||||
|
|
||||||
|
iterator = foo()
|
||||||
|
|
||||||
|
try:
|
||||||
|
next(iterator)
|
||||||
|
iterator.send(10)
|
||||||
|
iterator.send(20)
|
||||||
|
iterator.send(30)
|
||||||
|
except StopIteration:
|
||||||
|
pass
|
Loading…
Reference in New Issue
Block a user