This issue describes how to implement the generators concept 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 generators in Python.
Learning objectives
- Understand what generators are and how/when to use them
- Understand how generators relate to
loops and iterators
- Understand how to use the
yield keyword
- Understand the
__next__() method
- Create a generator
Out of scope
- Memory and performance characteristics and optimizations
throw(type, value=None, traceback=None)
close()
generator expressions
yield from
generators used as coroutines
Concepts covered
generators
yield
__next__()
iterators
Prerequisites
conditionals
dicts
functions
higher-order-functions
lists
loops
iteration
iterators
sequences
Resources to refer to
Hints
- Referring to one or more of the resources linked above, or analogous resources from a trusted source.
Generators section of the Python Docs Functional How to tutorial: Generators
Concept Description
(a variant of this can be used for the v3/languages/python/concepts/<concept>/about.md doc and this exercises introduction.md doc.)
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:
- Additional
Generator-iterator methods, such as generator.send() and generator.throw()
generator expressions
- Asynchronous generator functions
generators used as coroutines
Representer
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.TestCase and the test file named generators_test.py.
Code in the .meta/example.py file 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.
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.