Chapter 15

Creating and Using Classes

IN THIS CHAPTER

check Defining the characteristics of a class

check Specifying the class components

check Creating and using your own class

check 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.

remember 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 ...

Get Beginning Programming with Python For Dummies, 2nd 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.