[Python] Equivalent of Parameters helper from typescript in python

Discussão em 'Python' iniciado por Stack, Março 15, 2025.

  1. Stack

    Stack Membro Participativo

    In typescript it has a Parameters helper that get all types from function arguments:

    function sum(a: number, b: number) {
    return a + b
    }
    type SumParameters = Parameters<typeof sum>;
    function subtract(...params: SumParameters) {
    return params[0] - params[1]
    }


    How can I do the same in python so I don't need to redeclare all types again?

    This question is different from Python's equivalent of Typescript's Parameters utility type? once it's asking for ConstructorParameters

    Continue reading...

Compartilhe esta Página