O'Reilly logo

Pro Python, Second Edition by Marty Alchin, J.Burton Browning

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

image

Classes

In Chapter 3 you reviewed how functions allow you to define code that can be reused. This allowed for general code streamlining by not having to retype “chuncks” of code. However, it’s often more useful to combine those same functions into logical groupings that define the behavior and attributes of a particular type of object. This is standard object-oriented (OO) 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 ...

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