O'Reilly logo

Pro Python by Marty Alchin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 4. Classes

Although functions allow you to define code that can be reused, it's often more useful to combine those functions into logical groupings that define the behavior of a particular type of object. This is standard object-oriented programming, which is implemented in Python by way of types and classes. These, like functions, may seem simple enough on the surface, but there's a considerable amount of power behind them that you can leverage.

The most basic idea of a class is that it encapsulates the behavior of an object, while an instance of the class represents the data for the object. Therefore, even though data may well change from one instance to another, behavior determined by the underlying class will remain the same across ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required