I am learning coroutine fromwww.dabeaz.com/coroutines/pyos5.py and read the following code:
class GetTid(SystemCall):
def handle(self):
self.task.sendval = self.task.tid
self.sched.schedule(self.task)
def foo():
mytid = yield GetTid()
for i in range(10):
print("I'm foo", mytid)
yield
Reference to mytid = yield GetTid(),
I really confused about this,
is it mytid = (yield GetTid())?
The author use an instance as a variable to receive data. Is it a good pattern?
from mytid = yield GetTid() or mytid = (yield GetTid())
No comments:
Post a Comment