[Python-ideas] operator.call / operator.__call__
Jonas Wielicki
j.wielicki at sotecware.net
Thu Oct 30 10:08:10 CET 2014
On 30.10.2014 10:03, Andrew Barnert wrote:
> On Oct 30, 2014, at 1:23, Jonas Wielicki <j.wielicki at sotecware.net> wrote:
>
>> (only referring to the second use case here)
>>
>> On 30.10.2014 09:07, Antony Lee wrote:
>>> [snip]
>>> self.any_callable_signal.connect(lambda f: f()) # <- operator.call
>>> seems to express this better.
>>> def call_in_gui_thread(self, func):
>>> self.any_callable_signal.emit(func)
>>
>> How is that different from directly passing f? Or use functools.partial
>> in case you need to pass additional, fixed arguments to f.
>
> He's passing a function that takes any function f and calls it. That's not the same as passing any particular function.
>
> Maybe it's more obvious if you compare:
>
> lambda f: f()
> lambda: f()
>
Right, I missed that, sorry for the noise.
regards,
jwi
More information about the Python-ideas
mailing list