Lesson 3: Methods — what objects can do
Our objects have attributes — but they still don't do anything. In this lesson we add methods: functions defined inside the class that read the attributes through self and even change them.
If an attribute is what a dog has (name, age), a method is what the dog does (barks, celebrates a birthday). Both live in the same class.
- method
- A function defined inside a class that operates on the object through self.
- method call
- Invoking a method on a specific object: rex.bark().