Function that returns another function '->' symbol

Viewed 37

What is the -> symbol for returning a function from another function?

def OneFunc(x) -> def:
    return AnotherFunc

Does not seem to work, nor function / func ..

1 Answers

You want the Callable generic type.

from typing import Callable

def OneFunc(x: int) -> Callable[[], None]:
    return lambda: AnotherFunc('5', x)

The parameters to Callable depend on the signature of the function you're returning.

Related