Skip to Content
Mastering Python Design Patterns - Second Edition
book

Mastering Python Design Patterns - Second Edition

by Kamon Ayeva, Sakis Kasampalis
August 2018
Intermediate to advanced
248 pages
5h 51m
English
Packt Publishing
Content preview from Mastering Python Design Patterns - Second Edition

Real-world examples

Whenever you have a collection of things, and you have to go through the collection by taking those things one by one, it is an example of iterator pattern.

So, there are many examples in life, for instance as follows:

  • A classroom where the teacher is going to each student to give them their textbook
  • A waiter in a restaurant attending to people at a table, and taking the order of each person

What about software?

As we said, iteration is already in Python as a feature. We have iterable objects and iterators. Container or sequence types (list, tuple, string, dictionary, set, and so on) are iterable, meaning we can iterate through them. Iteration is done automatically for you whenever you use the for or while loop to traverse ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Python Design Patterns - Second Edition - Second Edition

Learning Python Design Patterns - Second Edition - Second Edition

Chetan Giridhar, Gennadiy Zlobin

Publisher Resources

ISBN: 9781788837484Supplemental Content