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