[Python] What are assignment expressions (using the "walrus" or ":=" operator)? Why was this...

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

  1. Stack

    Stack Membro Participativo

    Since Python 3.8, code can use the so-called "walrus" operator :)=), documented in PEP 572, for assignment expressions.

    This seems like a really substantial new feature, since it allows this form of assignment within comprehensions and lambdas.

    What exactly are the syntax, semantics, and grammar specifications of assignment expressions?

    Why was this new (and seemingly quite radical) concept introduced, even though PEP 379 (which proposes the similar idea of "Adding an assignment expression") was withdrawn?

    Continue reading...

Compartilhe esta Página