# Method (Programming)

> A function that belongs to an object. It can use that object's data.

**Field:** Software Development  
**Category:** Programming Paradigms  
**Also known as:** Method, Member Function

## Think of it like

Think of it like a trick a pet knows. You say the word, and that pet does its trick.

## Definition

A method is a function that belongs to an object or a class. It can read and change that object's own data. You call it with a dot after the object, like rex.speak() or "hello".upper(). The same method name can do different things on different kinds of object. In Python, a method's first input is usually called self, which means the object itself.

## Example

Lucy calls upper() on the word hello. The string method gives back HELLO, and the original word is unchanged.

## Example code

```python
>>> "hello".upper()
'HELLO'
```

upper is a method that every string has.

## Why it matters

Methods keep each action next to the data it works on. That makes code easier to find and change.

## Common mistake

Forgetting the brackets. rex.speak names the method; rex.speak() runs it.

## Three principles

- **Belongs to an object.** A function with a home.
- **Uses its data.** Through self or this.
- **Called with a dot.** Like rex.speak().

## Related terms

- [Function](https://learn.benibix.com/term/development/function)
- [Object (Programming)](https://learn.benibix.com/term/development/object)
- [Class](https://learn.benibix.com/term/development/class)
- [Function Call](https://learn.benibix.com/term/development/function-call)
- [Static Method](https://learn.benibix.com/term/development/static-method)
- [this and self](https://learn.benibix.com/term/development/this-and-self)

## Told apart from

- [Method vs Function](https://learn.benibix.com/compare/method-vs-function): A method is a function too, but it belongs to an object. A plain function stands alone; a method is called with a dot and can use its object's data.

---

Source: https://learn.benibix.com/term/development/method
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
