This chapter is about classes, a tool for creating new types of objects in Python. When you create a class, you put data (also called state) and behavior in one suitcase. Programs based on these suitcases of data-plus-behavior are easily customized.

Python also uses classes to organize many of its own features. For example, Python's built-in data types, such as strings and lists, are classes. The use of classes hides complexity from users who don't care about it. You can use a list without worrying about how lists work, and you can perform an action such as sorting a list without worrying about how sorting works. (And if you ever had to write a sort function, you know that's a good thing.)

In this chapter, you find out how to create and use these Python objects:

• Classes, subclasses, and superclasses

• Class methods

• Class instances

• Class and instance attributes

You also find out why classes are important to Python's modular design.

Was this article helpful?

0 0

Post a comment