I have modified some code from Coroutines as follows:
def grep(p1, p2):
print("Searching for", p1 ,"and", p2)
while True:
line = (yield)
if (p1 or p2) in line:
print(line)
search = grep('love', 'woman')
next(search)
search.send("I love you")
search.send("Don't you love me?")
search.send("I love coroutines instead!")
search.send("Beatiful woman")
Output:
Searching for love and woman
I love you
Don't you love me?
I love coroutines instead!
Second argument "woman"
is not recognized in the last search. Why is that?