Chapter 6. Python Data Structures
In our examples so far, we've already seen many of the built-in Python data structures in action. You've probably covered many of them in introductory books or tutorials. In this chapter, we'll be discussing the object-oriented features of these data structures, when they should be used instead of a regular class, and when they should not be used. In particular we'll be covering:
- Tuples
- Dictionaries
- Lists and sets
- How and why to extend built-in objects
Empty objects
Let's start with the most basic Python built-in, one that we've seen many times already, the one that we've extended in every class we have created: the object
. Technically, we can instantiate an object without writing a subclass:
>>> o = object() >>> o.x ...
Get Python 3 Object Oriented Programming 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.