Created
July 14, 2013 13:21
-
-
Save shigemk2/5994252 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#-*- coding:utf-8 -*-" | |
def psychologist(): | |
print('Please tell me your problems') | |
while True: | |
answer = yield | |
if answer is not None: | |
if answer.endswith('?'): | |
print("Don't ask yourself too much questions") | |
elif 'good' in answer: | |
print("A that's good, go on") | |
elif 'bad' in answer: | |
print("Don't be so negative") | |
free = psychologist() | |
print next(free) # # Please tell me your problems | |
# None | |
# sendを使うとyieldが渡された値を返す。 | |
free.send('I feel bad') # Don't be so negative | |
free.send("Why shouldn't?") # Don't ask yourself too much questions | |
free.send("ok then i should find what is good for me") # A that's good, go on |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment