liveBook · Manning

Method

As explained in Software Design for Python Programmers

A method is a function defined as part of a class that operates on or describes the behavior of its objects.

A method is a function defined as part of a class. It implements an object's behavior, usually operates on the object's instance variables, and is called through an object such as shape.draw(). section 2.3 section 1.8

Catalogue behavior

A Catalogue can provide add(), update(), delete(), and find() methods. Its add() method appends Book objects to the _booklist instance variable, keeping catalogue behavior with the state it changes. section 3.8.2

Distinguish methods from related callable behavior:

  • Call a regular method on an object of its class; call a static method on either the object or the class. section 2.3
  • Use methods to determine how an object's state changes during runtime. section 1.8
Table 3.3 Determine the behavior of each class

Verb

Class

Method

add

Catalogue

add() a book to the booklist.

update

Catalogue

update() a book in the booklist.

delete

Catalogue

delete() a book from the booklist.

search

Catalogue

find() matching books in the booklist.

verify

Form

verify() user input in the form fields.

match

Attributes

is_match() check if attributes match.

Map requirement verbs to class methods, including catalogue operations, form validation, and attribute matching. section 3.8.2

How Software Design for Python Programmers covers it

How deep it goes
Defines methods, contrasts regular and static invocation, and maps requirements verbs to concrete operations without detailing implementation internals.
Examples
Uses shape.draw(), Catalogue operations, form verification, and attribute matching as method examples.
What it assumes
Assumes basic Python familiarity while reviewing classes, objects, functions, instance variables, and core object-oriented concepts.
What you can do after
Build it from scratch by translating object-related requirements into methods that operate on class state.
How it connects
Connects methods with classes, objects, instance variables, functions, encapsulation, inheritance, and polymorphism.

Also explained in

Compare how 20 books explain method →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Software Design for Python Programmers. The section links point to the parts of the book it draws on.