This issue describes how to implement the iterators 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:
Goal
This concept exercise is meant to teach an understanding/creation/use of iterators in Python.
Learning objectives
Learn more about how looping / iteration and the iterator protocol work in Python, and the options available for creating & customizing iterators.
- How
loops in Python implement the iterator protocol
iteration "under the covers"
- How
iterables are defined
- Understand and use the built-in
iter() to return an iterator
- Create/use one or more custom
iterators via defining a class
- Understand how
class -created iterators relate to generators, and the pros and cons of each approach
Out of scope
classes & class customization beyond the use of the iterator dunder methods and iterator protocol
class-inheritance beyond what is needed to customize iteration for a container type or other class
comprehensions
comprehensions in lambdas
coroutines
decorators
functools and related map(), filter() and functools.reduce()
generators in-depth as a specific form of iterators (these have their own exercise)
higher-order functions
lambdas
- using an
assignment expression or "walrus" operator (:=)
- class decorators
enums
Concepts
loops
iteration
iterators & iterator types
iterator protocol
iterables
enumeration
Prerequisites
These are the concepts/concept exercises the student needs to complete/understand before solving this concept exercise.
basics
booleans
classes
comparisons
rich-comparisons
decorators
descriptors
dicts
dict-methods
functions
higher-order-functions
lists
list-methods
numbers
sequences
sets
strings
string-methods
tuples
Resources to refer to
Concept Description
Please see the following for more details on these files: concepts & concept exercises
-
Concept about.md
Concept file/issue: There is currently no issue or files for the concept. They are TBD.
For more information, see Concept about.md
- This file provides information about this concept for a student who has completed the corresponding concept exercise. It is intended as a reference for continued learning.
-
Concept introduction.md
For more information, see Concept introduction.md
- This can also be a summary/paraphrase of the document listed above, and will provide a brief introduction of the concept for a student who has not yet completed the concept exercise. It should contain a good summation of the concept, but not go into lots of detail.
-
Exercise introduction.md
For more information, see Exercise introduction.md
- This should also summarize/paraphrase the above document, but with enough information and examples for the student to complete the tasks outlined in this concept exercise.
Test-runner
No changes required to the Python Test Runner at this time.
Representer
No changes required to the Python Representer at this time.
Analyzer
No changes required to the Python Analyzer at this time.
Exercise Metadata - Track
For more information on concept exercises and formatting for the Python track config.json , please see concept exercise metadata. The track config.json file can be found in the root of the Python repo.
You can use the below for the exercise UUID. You can also generate a new one via exercism configlet, uuidgenerator.net, or any other favorite method. The UUID must be a valid V4 UUID.
- Exercise UUID :
087e3eec-33f4-4b7e-8335-a5ee9ddda9f3
- concepts should be filled in from the Concepts section in this issue
- prerequisites should be filled in from the Prerequisites section in this issue
Exercise Metadata Files Under .meta/config.json
For more information on exercise .meta/ files and formatting, see concept exercise metadata files
.meta/config.json - see this link for the fields and formatting of this file.
.meta/design.md - see this link for the formatting of this file. Please use the Goal, Learning Objectives,Concepts, Prerequisites and , Out of Scope sections from this issue.
Implementation Notes
- Code in the
.meta/examplar.py file should only use syntax & concepts introduced in this exercise or one of its prerequisite exercises.
- Please do not use comprehensions, generator expressions, or other syntax not previously covered. Please also follow PEP8 guidelines.
- In General, tests should be written using
unittest.TestCase and the test file should be named <EXERCISE-NAME>_test.py.
- While we do use PyTest as our test runner and for some implementation tests, please check with a maintainer before using a PyTest test method, fixture, or feature.
- Our markdown and JSON files are checked against prettier . We recommend setting prettier up locally and running it prior to submitting your PR to avoid any CI errors.
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
iteratorsconcept 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:
Goal
This concept exercise is meant to teach an understanding/creation/use of
iteratorsin Python.Learning objectives
Learn more about how
looping/iterationand theiterator protocolwork in Python, and the options available for creating & customizingiterators.loopsin Python implement theiterator protocoliteration"under the covers"iterablesare definediter()to return aniteratoriteratorsvia defining aclassclass-created iterators relate togenerators, and the pros and cons of each approachOut of scope
classes&class customizationbeyond the use of theiteratordunder methods anditerator protocolclass-inheritancebeyond what is needed to customizeiterationfor acontainer typeor otherclasscomprehensionscomprehensionsinlambdascoroutinesdecoratorsfunctoolsand relatedmap(),filter()andfunctools.reduce()generatorsin-depth as a specific form of iterators (these have their own exercise)higher-order functionslambdasassignment expressionor "walrus" operator (:=)enumsConcepts
loopsiterationiterators&iterator typesiterator protocoliterablesenumerationPrerequisites
These are the concepts/concept exercises the student needs to complete/understand before solving this concept exercise.
basicsbooleansclassescomparisonsrich-comparisonsdecoratorsdescriptorsdictsdict-methodsfunctionshigher-order-functionslistslist-methodsnumberssequencessetsstringsstring-methodstuplesResources to refer to
forstatementforLoops Work in Pythoniter()iteratorin PythoniteratorPatternHints
For more information on writing hints see hints
links.jsonFor more information, see concept links file
concepts/links.jsonfile, if it doesn't already exist.links.jsondocument.Concept Description
Please see the following for more details on these files: concepts & concept exercises
Concept
about.mdConcept file/issue: There is currently no issue or files for the concept. They are TBD.
For more information, see Concept
about.mdConcept
introduction.mdFor more information, see Concept
introduction.mdExercise
introduction.mdFor more information, see Exercise
introduction.mdTest-runner
No changes required to the Python Test Runner at this time.
Representer
No changes required to the Python Representer at this time.
Analyzer
No changes required to the Python Analyzer at this time.
Exercise Metadata - Track
For more information on concept exercises and formatting for the Python track
config.json, please see concept exercise metadata. The trackconfig.jsonfile can be found in the root of the Python repo.You can use the below for the exercise UUID. You can also generate a new one via exercism configlet, uuidgenerator.net, or any other favorite method. The UUID must be a valid V4 UUID.
087e3eec-33f4-4b7e-8335-a5ee9ddda9f3Exercise Metadata Files Under
.meta/config.jsonFor more information on exercise
.meta/files and formatting, see concept exercise metadata files.meta/config.json- see this link for the fields and formatting of this file..meta/design.md- see this link for the formatting of this file. Please use the Goal, Learning Objectives,Concepts, Prerequisites and , Out of Scope sections from this issue.Implementation Notes
.meta/examplar.pyfile should only use syntax & concepts introduced in this exercise or one of its prerequisite exercises.unittest.TestCaseand the test file should be named<EXERCISE-NAME>_test.py.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.