1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] Type for heterogeneous *args

Discussão em 'Python' iniciado por Stack, Setembro 11, 2024.

  1. Stack

    Stack Membro Participativo

    In typed Python, how do you type a *args list that you're expecting to pass to another argument that is a higher kinded function?

    For example, this function takes a function and its first argument and internally just routes *args through, but its type signature depends on the type of that, possibly heterogeneous, argument list:

    def curry_one[T, R](x: T, f: Callable[[T, WHAT_GOES_HERE], R]) -> Callable[[WHAT_GOES_HERE], R]:
    def curried(*args: WHAT_GOES_HERE) -> R:
    return f(x, *args)
    return curried


    Can Expand be used with a generic type parameter over some kind of heterogeneous array?

    (I'm not interested in a curry function in the standard library. I'm writing some specific function adapters and am just using curry as an example.)

    Continue reading...

Compartilhe esta Página