Join Jungwoo Ryoo for an in-depth discussion in this video Iterator example, part of Python: Design Patterns.
- Now let's define our own iterator.…We start with creating our own list.…As you can see here, the list we are using…is a list of these German words,…counting up to five.…Here we'll be using a built in iterator…provided by Python.…The iterator will create a tuple,…such as one and the German word,…for example eins.…So the iterator will return five tuples.…So in this case, the tuple means a pair.…
So one, eins, that's a tuple.…Two, zwei, that's another tuple.…So there will be five tuples returned in total.…To make it happen, we need to add a line of code.…We're using the built in iterator called zip,…Z-I-P.…And then, since we have to provide the number…from one through five, that's why…we are using this function, range,…R-A-N-G-E.…
And the argument of that function we're…using is the number of words that will be…provided as an argument of this function.…So I'll be using count.…And then the second argument of this function…is the list itself.…So numbers in German.…The range argument here is important…because it allows us to know…
- Understanding design patterns
- Best design practices: consistency, completeness, and correctness
- Working with creational patterns
- Working with structural patterns
- Working with behavioral patterns
Skill Level Intermediate
Q: In the strategy pattern example, why does the code keep executing the default function rather than the alternate?
A: The programming demonstration skips the step of defining what the strategy pattern should be when an alternate function name is provided
as an argument as shown below.
Programming Foundations: Design Patternswith Elisabeth Robson2h 19m Intermediate
1. Understanding Design Patterns
2. Creational Patterns
3. Structural Patterns
4. Behavioral Patterns
5. Design Best Practices
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.