Chapter 15
Creating and Using Classes
IN THIS CHAPTER
Defining the characteristics of a class
Specifying the class components
Creating and using your own class
Working with subclasses
You’ve already worked with a number of classes in previous chapters. Many of the examples are easy to construct and use because they depend on the Python classes. Even though classes are briefly mentioned in previous chapters, those chapters largely ignore them simply because discussing them wasn’t immediately important.
Classes make working with Python code more convenient by helping to make your applications easy to read, understand, and use. You use classes to create containers for your code and data, so they stay together in one piece. Outsiders see your class as a black box — data goes in and results come out.
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.
Read now
Unlock full access
At some point, you need to start constructing classes of your own if you want to avoid the dangers of the spaghetti code that is found in older applications. Spaghetti code is much as the ...