[Python] What do ** (double star/asterisk) and * (star/asterisk) mean in a function call?

Discussão em 'Python' iniciado por Stack, Fevereiro 3, 2025.

  1. Stack

    Stack Membro Participativo

    In code like zip(*x) or f(**k), what do the * and ** respectively mean? How does Python implement that behaviour, and what are the performance implications?


    See also: Expanding tuples into arguments. Please use that one to close questions where OP needs to use * on an argument and doesn't know it exists. Similarly, use Converting Python dict to kwargs? for the case of using **.

    See What does ** (double star/asterisk) and * (star/asterisk) do for parameters? for the complementary question about parameters.

    See What do ** (double star/asterisk) and * (star/asterisk) inside square brakets mean for class and function declarations in Python 3.12+? for the complementary question when used for type parameters.

    Continue reading...

Compartilhe esta Página