I am following the Python tutorial.
def make_incrementor(n): return lambda x: x + n Result:
f = make_incrementor(42) print(f(1)) 43 print(type(f)) <class 'function'> Now consider we will replace the lambda expression by a regular function
def nolambda(x): return x def make_incrementor(n): return nolambda(n) f = make_incrementor(42) print(type(f)) <class 'int'> In the first case it returned <class 'function'> but in the second it returned <class 'int'>
It only points to the lamba expression in the first case and do not execute it (ok, it would raise an error because of the missing argument). I could understand that but it returns an int rather than a function in the second example, so it is very strange to me. Could you explain what's going on?
nolambdajust returns its argument, so when you returnnolambda(n)you yet again return your argument.