You should interpret this as a function object or a functor.
myfunc.<locals>.<lambda> its just says that it is a local variable of myfunc and its a lambda function.
myfunc(2) # is a function object
print(myfunc(2)(3)) # prints 6 which is 3 * 2
This function stores the inner variable n = 2 and then returns the called value. This concept is called functional closure.
You can get into more detail if you disassembled and dive deep if you want.
from dis import dis
def myfunc(n):
return lambda a:a*n
dis(myfunc)
OUTPUT
➜ codebase git:(master) ✗ python temp.py
3 0 LOAD_CLOSURE 0 (n)
2 BUILD_TUPLE 1
4 LOAD_CONST 1 (<code object <lambda> at 0x7fc5f671f5d0, file "temp.py", line 3>)
6 LOAD_CONST 2 ('myfunc.<locals>.<lambda>')
8 MAKE_FUNCTION 8
10 RETURN_VALUE
Disassembly of <code object <lambda> at 0x7fc5f671f5d0, file "temp.py", line 3>:
3 0 LOAD_FAST 0 (a)
2 LOAD_DEREF 0 (n)
4 BINARY_MULTIPLY
6 RETURN_VALUE