boB Stepp 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
r
On Fri, Sep 30, 2016 at 6:55 AM, Steven D'Aprano wrote:
> On Thu, Sep 29, 2016 at 09:43:57PM -0500, boB Stepp wrote:
>> But why does Python require
>> separating the function object from its parameters when it is being
>> passed as an argument to another function?
>
> If you pass the function arg
On Fri, Sep 30, 2016 at 3:43 AM, Alan Gauld via Tutor wrote:
> On 30/09/16 03:43, boB Stepp wrote:
>
>> Also, I note that if I just type a function name without the
>> parentheses in the interpreter, I will get something like this:
>>
> def f():
>>pass
>>
> f
>>
>>
>> So the i
On Fri, Sep 30, 2016 at 09:43:47AM +0100, Alan Gauld via Tutor wrote:
> On 30/09/16 03:43, boB Stepp wrote:
>
> > Also, I note that if I just type a function name without the
> > parentheses in the interpreter, I will get something like this:
> >
> def f():
> >pass
> >
> f
On Thu, Sep 29, 2016 at 09:43:57PM -0500, boB Stepp wrote:
> I believe I understand the barebone mechanics on how to do this. But
> I do not understand the rationale of why Python does it the way it
> does. Say
>
> def f(g, *args):
> g(*args)
Right. This says:
- Define a function called "
On 30/09/16 03:43, boB Stepp wrote:
> Also, I note that if I just type a function name without the
> parentheses in the interpreter, I will get something like this:
>
def f():
>pass
>
f
>
>
> So the impression I am getting is that a function name by itself (with
> no pare
boB Stepp writes:
> So the impression I am getting is that a function name by itself (with
> no parentheses) is the function *object*.
Yes. The expression ‘func’ resolves to whatever object is referenced by
that name; if it's a function object, you get that object.
The expression ‘func(foo, bar