|
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…
|
|
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.
|
|
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…
|
|
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…
|
|
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.
|
|
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.…
|
|
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.
|