Lesson 32. Working with your own object types
After reading lesson 32, you’ll be able to
- Define a class to simulate a stack
- Use a class with other objects you define
At this point, you know how to create a class. Formally, a class represents an object type in Python. Why do you want to make your own object types in the first place? Because an object type packages a set of properties and a set of behaviors in one data structure. With this nicely packaged data structure, you know that all objects that take on this type are consistent in the set of data that defines them, and consistent in the set of operations that they can perform.
The useful idea behind object types is that you can build upon object types you create to make objects that are ...
Get Get 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.