Search for tag: "iterator"

Lesson 28.3 The yield Statement

Making iterator classes is hard. In this video, we show an alternative, allowing us to write the iterator as a ‘function”. This requires the addition of a new python statement, the yield…

From  Hannah Lee 61 plays

Lesson 28.2 Iterable Classes

In this video, we show how to make our own iterable and iterator classes. These are actually tightly linked, and you need one to create the other.

From  Hannah Lee 75 plays

Lesson 28.1 Iterators

We are familiar with iterables, types that we can use in a for-loop. In this video we introduce the iterator. This is a type that can be used in a for-loop, but we can also manually step through the…

From  Hannah Lee 69 plays

Lesson 26.6 Mutable While-Loops

In this video we show that the one place we typically prefer while-loops is when we are modifying a list or other mutable iterable. While we did see how to do this with for-loops (by looping over…

From  Hannah Lee 67 plays

Lesson 26.5 While-Loops vs For-Loops

We can always replace for-loops with while-loops, but should we? In this video we talk about the trade-offs of the two control structures and why it might be better to use over the other.

From  Hannah Lee 72 plays

Lesson 26.3 While-Loop Ranges

While-loops require additional patterns beyond the simple accumulator pattern that we used in for-loops. In this video, we talk about the first such pattern, which is replacing the range iterator.…

From  Hannah Lee 73 plays

Lesson 26.1 The While-Loop

In this video we talk about the while-loop and explain why it is necessary. In particular, there are types of iteration that are not possible with the for-loop.

From  Hannah Lee 81 plays