[Python-ideas] operator.call / operator.__call__
Andrew Barnert
abarnert at yahoo.com
Thu Oct 30 10:03:59 CET 2014
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()
More information about the Python-ideas
mailing list