9 Using classes beyond the basics
This chapter covers
- Creating enumerations
- Eliminating boilerplate of a custom class
- Processing JSON data
- Creating lazy attributes
- Refactoring a cumbersome class
Python is an object-oriented language at its core. The hallmark of an object-oriented language is using objects to preserve data and provide functionalities, which generally requires you to implement well-defined custom classes. In chapter 8, you learned the essential techniques for defining a class. But many other techniques can help us define more robust custom classes so that we can build a more maintainable codebase with well-defined data models.
Custom classes typically require implementation of several special methods, for example, including ...
Get Python How-To 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.