Closed
Description
This issue describes how to implement the generator-expressions
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:
- Contributing to Exercism | Exercism and GitHub | Contributor Pull Request Guide
- What are those Weird Task Tags about?
- Building Language Tracks: An Overview
- What are Concepts?
- Concept Exercise Specifications
- Concept Specifications
- Exercism Formatting and Style Guide
- Exercism Markdown Specification
- Reputation
Goal
The goal of this exercise is to teach the syntax and variants of generator expressions
in Python.
Learning objectives
- Understand how a
generator expression
relates to both alist comprehension
and agenerator
- Understand where
generator expressions
can and cannot be utilized - Create a
generator expression
- Use a generator expression as an argument to a function such as
''.join()
orsum()
- Use a generator expression as an element of a comprehension
Out of scope
- Memory and performance characteristics and optimizations
- Generator methods such as
throw()
andclose()
- Using the
assignment expression
(walrus operator) with agenerator expression
Concepts
generator expressions
Prerequisites
basics
conditionals
comparisons
loops
generators
iterators
iteration
list-comprehensions
other-comprehensions
Resources to refer to
- Generator expressions and list comprehensions (Python official docs)
- Generators (Python official docs)
- List Comprehensions (Python official docs)
- Generator Expressions in Python (Dan Bader)
Hints
Generator Expressions
section of the Python docs tutorial: Generator expressions and list comprehensions (Python official docs)- Generator Expressions in Python (Dan Bader)
After
- Additional
Generator-iterator methods
, such asgenerator.send()
andgenerator.throw()
generator expressions
- Asynchronous generator functions
generators
used as coroutines
Representer
No changes required.
Analyzer
No changes rquired.
Implementing
- Tests should be written using unittest.TestCase, and the test file named list_comprehensions_test.py.
- How to Implement a Concept Exercise in Python
- make-concept-exercise Utility
Help
If you have any questions while implementing the exercise, please post the questions as comments in this issue.