Type annotation for function returning a lambda Type annotation for function returning a lambda python-3.x python-3.x

Type annotation for function returning a lambda


You can use Callable to type hint the return:

from typing import Callabledef line(slope: float, b : float) -> Callable[[float], float]:     return lambda x: slope*x + b