Basics of Classes and Objects

In this chapter, we will look at the following recipes:

  • Using a class to encapsulate data and processing
  • Designing classes with lots of processing
  • Designing classes with little unique processing
  • Optimizing small objects with __slots__
  • Using more sophisticated collections
  • Extending a collection – a list that does statistics
  • Using properties for lazy attributes
  • Using settable properties to update eager attributes

Get Modern Python Cookbook 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.