Search for tag: "iterator"
Lesson 28.3 The yield StatementMaking 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
63 plays
|
|
Lesson 28.2 Iterable ClassesIn 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
78 plays
|
|
Lesson 28.1 IteratorsWe 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
72 plays
|
|
Lesson 26.6 Mutable While-LoopsIn 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
71 plays
|
|
Lesson 26.5 While-Loops vs For-LoopsWe 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
79 plays
|
|
Lesson 26.3 While-Loop RangesWhile-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
79 plays
|
|
Lesson 26.1 The While-LoopIn 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
86 plays
|