8 Defining user-friendly classes

This chapter covers

  • Defining the initialization method
  • Creating instance, static, and class methods
  • Applying encapsulation to a class
  • Creating proper string representations
  • Defining a superclass and subclasses

The core of any application is data. Although built-in data types are useful for managing data, you’ll find them to be limited because they only have attributes and methods that are designed to address the most generic functionalities, including named tuples (section 3.3). You may have noticed that you don’t have useful methods to manipulate tasks with named tuples. But the task management app (like all applications in general) addresses specific business needs, which require data models that can handle ...

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.