Reputation: 309
apologies if this question is too basic/obvious, but I can't find a reasonable answer after searching both here and through the data model docs.
My question is simply, what exactly is a caller in python 3? Is there a strict definition?
I know for example a function that calls another function is known as a caller. So:
def f1():
pass
def f2():
f1()
f2 is the caller of f1. But what about assignment statements?
x = f2()
Is x a caller of f2? Is it also a caller of f1? It's obviously been stated that the return statement at the end of a function definition returns a value to the caller, so I would assume in this case x is both a caller of f2 and f1, however I just want to check that there is no deeper/technical meaning to what a caller is?
I found this question I don't understand "return" in Python and what is a caller?, but I couldn't get much understanding.
Upvotes: 5
Views: 7203
Reputation: 51000
The caller of a function is the unit of program code in which the call to the function occurred. This can be another function, a method (a specific type of function) or, in Python, the code in the "top level" of a python source code file -- generally referred to as a script.
Upvotes: 4