-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[New Concept Exercise] : generators #2293
Copy link
Copy link
Closed
Labels
claimed 🐾For new exercises being written by contributors and maintainers.For new exercises being written by contributors and maintainers.x:action/createWork on something from scratchWork on something from scratchx:knowledge/advancedComprehensive Exercism knowledge requiredComprehensive Exercism knowledge requiredx:module/concept-exerciseWork on Concept ExercisesWork on Concept Exercisesx:rep/largeLarge amount of reputationLarge amount of reputationx:size/largeLarge amount of workLarge amount of workx:status/claimedSomeone is working on this issueSomeone is working on this issue
Metadata
Metadata
Assignees
Labels
claimed 🐾For new exercises being written by contributors and maintainers.For new exercises being written by contributors and maintainers.x:action/createWork on something from scratchWork on something from scratchx:knowledge/advancedComprehensive Exercism knowledge requiredComprehensive Exercism knowledge requiredx:module/concept-exerciseWork on Concept ExercisesWork on Concept Exercisesx:rep/largeLarge amount of reputationLarge amount of reputationx:size/largeLarge amount of workLarge amount of workx:status/claimedSomeone is working on this issueSomeone is working on this issue
This issue describes how to implement the
generatorsconcept exercise for the Python track.Getting started
Please please please read the docs before starting. Posting PRs without reading these docs will be a lot more frustrating for you during the review cycle, and exhaust Exercism's maintainers' time. So, before diving into the implementation, please read up on the following documents:
Please also watch the following video:
Goal
The goal of this exercise is to teach the syntax and use of
generatorsin Python.Learning objectives
loopsanditeratorsyieldkeyword__next__()methodOut of scope
throw(type, value=None, traceback=None)close()generator expressionsyield fromgeneratorsused as coroutinesConcepts covered
generatorsyield__next__()iteratorsPrerequisites
conditionalsdictsfunctionshigher-order-functionslistsloopsiterationiteratorssequencesResources to refer to
Hints
Generatorssection of the Python Docs Functional How to tutorial: GeneratorsConcept Description
(a variant of this can be used for the
v3/languages/python/concepts/<concept>/about.mddoc and this exercisesintroduction.mddoc.)Concept Description Needs to Be Filled In Here/Written
Some "extras" that we might want to include as notes in the concept description, or as links in
links.json:Generator-iterator methods, such asgenerator.send()andgenerator.throw()generator expressionsgeneratorsused as coroutinesRepresenter
No changes required.
Analyzer
No changes rquired.
Implementing
The general Python track concept exercise implantation guide can be found here.
Tests should be written using
unittest.TestCaseand the test file namedgenerators_test.py.Code in the
.meta/example.pyfile should only use syntax & concepts introduced in this exercise or one of its prerequisites. Please do not use comprehensions, generator expressions, or other syntax not previously covered. Please also follow PEP8 guidelines.Help
If you have any questions while implementing the exercise, please post the questions as comments in this issue, or contact one of the maintainers on our Slack channel.