Skip to content
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

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from
Open

Conversation

stevendes
Copy link
Owner

Completed and ready for review!

@stevendes stevendes requested a review from glpuga January 3, 2020 15:52
Copy link
Collaborator

@glpuga glpuga left a 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)
Copy link
Collaborator

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
Copy link
Collaborator

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)
Copy link
Collaborator

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)'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Key point!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants