Hasil Python dari
# In python construction 'yield from something' is just
# the abbreviation of 'for i in something: yield i'
# So, we can change this:
def yieldOnly():
yield "A"
yield "B"
yield "C"
def yieldFrom():
for _ in [1, 2, 3]:
yield from yieldOnly()
test = yieldFrom()
for i in test:
print(i)
# to this:
def yieldOnly():
yield "A"
yield "B"
yield "C"
def yieldFrom():
for _ in [1, 2, 3]:
for i in yieldOnly():
yield i
test = yieldFrom()
for i in test:
print(i)
Jittery Jay