-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Launch plane tickets concept exercise in beta (#3530)
* Tweak plane tickets concept exercise I did a small pass through to tweak it a bit for flow and readability. This exercise is ready to be launched. * Turn on plane tickets exercise * (BG) Rather More Edits than Anticipated: This all started with me re-editing the docstrings to comply with https://peps.python.org/pep-0257/, but then it snowballed. Turns out that typing.Generator (https://docs.python.org/3/library/typing.html#typing.Generator) has been deprecated as an alias, so the tests needed some love...and that snowballed into reviewing the other docs. Also renamed the stub and test files to be in line with what we did with other concept exercises. --------- Co-authored-by: BethanyG <BethanyG@users.noreply.github.com>
Showing
12 changed files
with
272 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
# Introduction | ||
|
||
A generator in Python is a _callable function_ that returns a [lazy iterator][lazy iterator]. | ||
A generator in Python is a _callable function_ or expression that returns a special type of [iterator][iterator] called [generator iterator][generator-iterator]. | ||
`Generator-iterators` are [lazy][lazy iterator]: they do not store their `values` in memory, but _generate_ their values when needed. | ||
|
||
_Lazy iterators_ are similar to `lists`, and other `iterators`, but with one key difference: They do not store their `values` in memory, but _generate_ their values when needed. | ||
A generator function looks like any other function, but contains one or more [yield expressions][yield expression]. | ||
Each `yield` will suspend code execution, saving the current execution state (_including all local variables and try-statements_). | ||
When the generator function resumes, it picks up state from the suspension - unlike regular functions which reset with every call. | ||
|
||
[lazy iterator]: https://en.wikipedia.org/wiki/Lazy_evaluation | ||
[iterator]: https://docs.python.org/3.11/glossary.html#term-iterator | ||
[yield expression]: https://docs.python.org/3.11/reference/expressions.html#yield-expressions | ||
[generator-iterator]: https://docs.python.org/3.11/glossary.html#term-generator-iterator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.