[Tutor] Passing functions as arguments to other functions
Ben Finney
ben+python at benfinney.id.au
Sat Oct 1 00:22:46 EDT 2016
boB Stepp <robertvstepp at gmail.com> writes:
> I think this was my key point of confusion. I was mistakenly thinking
> of f(x) as referring to the function object.
Right.
‘f’ is an expression, that Python resolves as whatever object ‘f’
references.
‘f(x)’ is an expression, that Python resolves by *calling* the object
referenced by ‘f’, and resolves to whatever object that call returns.
Both of them are expressions. ‘f’ is rightly termed a reference in both
of them. Only the first expression (the name ‘f’ alone) is reasonably
termed a reference.
> Instead, it is calling that object with argument x
I hope it will help for you to think in terms of “What value does this
expression resolve to?”
--
\ “Alternative explanations are always welcome in science, if |
`\ they are better and explain more. Alternative explanations that |
_o__) explain nothing are not welcome.” —Victor J. Stenger, 2001-11-05 |
Ben Finney
More information about the Tutor
mailing list