On Mon, Apr 11, 2016, at 04:01, Steven D'Aprano wrote: > What tuple that is passed to FunctionType.__call__? > > Where is the tuple in these examples? > > > py> from types import FunctionType > py> FunctionType.__call__(lambda x: x+1, 23) > 24 > py> FunctionType.__call__(lambda x, y: str(x)+str(y), 23, 42) > '2342' > > I don't see any evidence of a tuple being involved anywhere visible from > Python code.
The fact that it can be called with two positional arguments in your first example, and three in your second, is itself weak evidence for this (more evidence is needed to show that these aren't keyword/positional arguments with defaults) - a pure python function that behaved as FunctionType.__call__ would have to be defined with *args and **kwargs. And, indeed... >>> inspect.signature(FunctionType.__call__) <Signature (self, /, *args, **kwargs)> I am assuming that *args' use of a tuple is defined as part of the language. If I'm mistaken and it can be any sequence, I suppose I stand corrected. > How do you know that there's a tuple involved? (That's not a > rhetorical question, I am genuinely curious.) -- https://mail.python.org/mailman/listinfo/python-list