yield文(がちメモ
def hoge(): print "Tell me your mind" while True: ans = yield if ans is not None: if "?" in ans: print "it's question" elif "good" in ans: print "sound good" else: print "FUCK U" free = hoge() next(free) free.send("I want?") free.send("Today i was so good") free.send("U want?") free.send("I am wannabe")
のようなyield文を書いたら
⬇のような結果が返ってくる( ๑・ิټ・ิ๑)
Tell me your mind it's question sound good it's question FUCK U
正直悪いけど、何のためにあるのか分からない。
あっ、っていうか yield文はあくまでも関数をイタレータにするために
あるものなので、よくわからないw
分かる方教えてください