Python Functions vs Methods Explained Clearly
A clear beginner guide to Python functions vs methods. Learn the real difference, how each one is called, and the small mental model that makes the distinction permanent.
The Python functions vs methods question shows up the moment a beginner moves past the first few examples. Both look like named blocks of code that you call with parentheses, and both can take arguments and return values. The difference is not cosmetic. A function is a standalone callable. A method is a function that is permanently attached to a value of some type. The distinction shapes how you call it, how you read documentation, and how you decide which one to write yourself.
What a Python Function Really Is
A Python function is a named, callable object that exists independently of any value. You define it with the def keyword, give it a name, list its parameters in parentheses, and write its body indented underneath. You call it by writing its name followed by parentheses with the arguments inside. The function does not belong to anything. It lives in whatever scope it was defined in, usually a module or another function.
Built-in functions like len, range, and print follow this exact shape. You can pass them any value of any compatible type and the function decides what to do based on the argument. A function does not implicitly receive the object you are working on. Every value it operates on has to be passed in as a parameter, which is why function signatures often list two or three arguments even for small jobs. For a deeper picture of how functions sit in a Python program, our walkthrough on Python functions explained with real use cases covers definitions and call sites step by step.
What a Python Method Really Is
A Python method is a function defined inside a class, bound to instances of that class. You call it through the dot syntax, writing the value first, a dot, the method name, and then parentheses with any extra arguments. The receiver, which is the value on the left of the dot, is passed in automatically as the first argument of the method, named self by convention. That single piece of plumbing is the only mechanical difference between a method and a regular function.
Every built-in type ships with methods. A list has append, sort, and pop. A string has upper, split, and replace. A dictionary has keys, values, and items. These methods exist because each type knows how to operate on its own data. When you call words.split, you are saying that words is the input, and the split method already knows how to act on a string because it was defined as part of the str class. To see how the receiver model plays out for one of the most used types in the language, our piece on Python strings explained beyond just text walks through several string methods.
A Side by Side Look
The same task can usually be expressed as either a function call or a method call. The choice depends on which one reads more naturally and which one already exists in the language. The table below pins down the practical differences that you will care about as a beginner.
| Aspect | Function | Method |
|---|---|---|
| Defined where | Top level of a module or inside another function | Inside a class body |
| Call syntax | func(value) | value.method() |
| Receiver | Passed explicitly as an argument | Implicit, becomes self |
| Belongs to | A module namespace | A type or instance |
| Documentation lookup | help(func) | help(type(x).method) |
A tiny code example makes the two call shapes concrete:
len("hello")
"hello".upper()The first line calls a function and passes the string as its argument. The second line calls a method on the string itself, with the string acting as the implicit receiver. The table also explains why beginners sometimes mix the two up in error messages. An AttributeError happens when you try to call a method on a type that does not define it. A TypeError happens when you pass the wrong number of arguments to a function.
When to Write a Function or a Method
If the code you are writing operates on a single value of some type and the operation feels like part of that type's natural behaviour, a method is the right shape. If the code operates on several values, or coordinates between values of different types, or does not really belong to any single type, a function is the right shape. The third option, a static method or a module level function inside a class, is rare in beginner code and you do not need it yet.
A useful test is to read the call site you would write. If the most natural sentence is "ask the value to do something", write a method. If the most natural sentence is "do something with these values", write a function. Both shapes are first class in Python, and the language itself uses both extensively. To see how scope rules apply equally to both, our guide on Python global vs local variables explained visually covers the scoping that both functions and methods share.
Frequently Asked Questions
What is the difference between a function and a method in Python?
Why is the first parameter of a method called self?
Can I turn a function into a method or the other way around?
Conclusion
A function is a standalone callable that you pass arguments to. A method is a function attached to a type, called through the dot syntax, with the receiver becoming the first argument automatically. The line between the two is mechanical, not philosophical, and once you can see the implicit self argument in every method call, the distinction stops feeling slippery. The fastest way to lock in the model is to write the same small piece of logic twice, once as a function that takes the value as a parameter and once as a method on a small class. Calling both side by side and comparing the syntax makes the difference visible. After a single exercise like that, every future call site reads as one or the other without conscious thought.
More in this topic
Python Dictionary Comprehensions Explained with Examples
A practical beginner guide to Python dictionary comprehensions. Learn the syntax, the filter clause, the inversion pattern, and when to reach for a regular loop instead.
Python List Comprehensions Explained Step by Step
A step by step beginner guide to Python list comprehensions. Learn the shape, the filter clause, the nested form, and when to reach for a regular loop instead.
Python *args and **kwargs Explained the Easy Way
A clear beginner guide to Python *args and **kwargs. Learn what the stars do, how to use both in function signatures, and the patterns that make flexible functions readable.