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 ...
Get Pro Python 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.