iterator send

This commit is contained in:
Mert Gör ☭ 2023-09-06 19:48:25 +03:00
parent 173498f32b
commit b01dea087f
No known key found for this signature in database
GPG Key ID: 2100A876D55B39B9
1 changed files with 17 additions and 0 deletions

View 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