-
Notifications
You must be signed in to change notification settings - Fork 0
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
Completed the about_generators koan #19
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?
@@ -103,17 +103,18 @@ def test_generators_can_act_as_coroutines(self): | |||
# | |||
# 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.
@@ -19,7 +19,7 @@ def test_generating_values_on_the_fly(self): | |||
n in ['crunchy', 'veggie', 'danish']) | |||
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.
@@ -131,11 +132,11 @@ def test_generators_can_see_if_they_have_been_called_with_a_value(self): | |||
|
|||
generator2 = self.yield_tester() | |||
next(generator2) | |||
self.assertEqual(__, next(generator2)) | |||
self.assertEqual('no value', next(generator2)) | |||
|
|||
def test_send_none_is_equivalent_to_next(self): | |||
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!