Great question! In Python programming (and in programming in general), the term "function definition" is most accurately used to refer to the entire construct that defines a function: both the function header (the def line) and the function body (the indented block of code that follows).
Standard Usage
- Function header: The line that starts with
def, including the function name and parameters.
- Function body: The indented block of code under the header.
- Function definition: The combination of the header and the body.
Example:
def greet(name): # <-- function header
print("Hello,", name) # <-- function body
# The above together is the function definition
Misunderstandings
- Some beginners or people speaking informally might refer to just the
def line as the "function definition," but this is not technically correct.
- The
def line alone is more precisely called the function header or function signature.
In Summary
- Correct: "Function definition" = header + body.
- Incorrect (but sometimes heard): "Function definition" = just the
def line.
References
- Python official documentation: "A function definition introduces the function name and the function’s parameters. The body of the function is indented..."
- PEP 8: Uses "function definition" to mean the whole construct.
In short:
Yes, some people may use the term "function definition" to mean just the def line, but the correct and standard meaning is the def line plus the indented body. If you want to be precise, use "function header" for the def line and "function definition" for the whole thing.