I want to know how we get the value returned by a function - what the python return statement actually returns.
Considering following piece of code:
def foo():
y = 5
return y
When invoking foo()
, we get the value 5
.
x = foo()
x
binds the integer object 5
.
What does it mean? What does the return statement actually return here? The int
object 5
? Or variable name y
? Or the binding to the object 5
? Or something else?
How do we get the value returned by the return statement?