4
Pythonic Design Patterns
The previous chapter covered a lot of guidelines for what to do and what to avoid in Python. Next, we will explore a few examples of how to work in a Pythonic way using the modules included with Python.
Design patterns are largely dependent on storing data; for this, Python comes bundled with several very useful collections. The most basic collections such as list
, tuple
, set
, and dict
will already be familiar to you, but Python also comes bundled with more advanced collections. Most of these simply combine the basic types for more powerful features. In this chapter, I will explain how to use these data types and collections in a Pythonic fashion.
Before we can properly discuss data structures and related performance, ...
Get Mastering Python - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.