Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Mastering Python Design Patterns
  • Table Of Contents Toc
  • Feedback & Rating feedback
Mastering Python Design Patterns

Mastering Python Design Patterns

By : Kamon Ayeva, Kasampalis, Sakis Kasampalis
4.3 (8)
close
close
Mastering Python Design Patterns

Mastering Python Design Patterns

4.3 (8)
By: Kamon Ayeva, Kasampalis, Sakis Kasampalis

Overview of this book

As software systems become increasingly complex, maintaining code quality, scalability, and efficiency can be a daunting challenge. Mastering Python Design Patterns is an essential resource that equips you with the tools you need to overcome these hurdles and create robust, scalable applications. The book delves into design principles and patterns in Python, covering both classic and modern patterns, and apply them to solve daily challenges as a Python developer or architect. Co-authored by two Python experts with a combined experience of three decades, this new edition covers creational, structural, behavioral, and architectural patterns, including concurrency, asynchronous, and performance patterns. You'll find out how these patterns are relevant to various domains, such as event handling, concurrency, distributed systems, and testing. Whether you're working on user interfaces (UIs), web apps, APIs, data pipelines, or AI models, this book equips you with the knowledge to build robust and maintainable software. The book also presents Python anti-patterns, helping you avoid common pitfalls and ensuring your code remains clean and efficient. By the end of this book, you'll be able to confidently apply classic and modern Python design patterns to build robust, scalable applications.
Table of Contents (17 chapters)
close
close
Free Chapter
1
Part 1: Start with Principles
4
Part 2: From the Gang of Four
8
Part 3: Beyond the Gang of Four

The Iterator pattern

In programming, we use sequences or collections of objects a lot, particularly in algorithms and when writing programs that manipulate data. One can think of automation scripts, APIs, data-driven apps, and other domains. In this chapter, we are going to see a pattern that is useful whenever we must handle collections of objects: the Iterator pattern.

Note, according to the definition given by Wikipedia

Iterator is a design pattern in which an iterator is used to traverse a container and access the container’s elements. The iterator pattern decouples algorithms from containers; in some cases, algorithms are necessarily container-specific and thus cannot be decoupled.

The Iterator pattern is extensively used in the Python context. As we will see, this translates into Iterator being a language feature. It is so useful that the language developers decided to make it a feature.

Use cases for the Iterator pattern

It is a good idea to use the Iterator...

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech
bookmark search playlist download font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY