-
Notifications
You must be signed in to change notification settings - Fork 0
Completed the about_generators koan #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: devel
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work, some questions for you to answer.
self.assertEqual(__, attempt1) | ||
self.assertEqual(__, attempt2) | ||
self.assertEqual(['Boom!', 'Boom!', 'Boom!'], attempt1) | ||
self.assertEqual([], attempt2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this?
# | ||
# Hint: Read the "Specification: Sending Values into Generators" | ||
# section of http://www.python.org/dev/peps/pep-0342/ | ||
#I think is because the generator has just been created so it's not prepared yet to receive a value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's right.
for bacon in bacon_generator: | ||
result.append(bacon) | ||
self.assertEqual(__, result) | ||
self.assertEqual(['crunchy bacon', 'veggie bacon', 'danish bacon'], result) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Q: Research about tuple generators and tell me what you find.
generator = self.yield_tester() | ||
|
||
next(generator) | ||
# 'next(generator)' is exactly equivalent to 'generator.send(None)' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Key point!
Completed and ready for review!