[Python] How do chained assignments work?

Discussão em 'Python' iniciado por Stack, Agosto 28, 2025.

  1. Stack

    Stack Membro Participativo

    A quote from something:

    >>> x = y = somefunction()


    is the same as

    >>> y = somefunction()
    >>> x = y


    Question: Is

    x = y = somefunction()


    the same as

    x = somefunction()
    y = somefunction()


    ?

    Based on my understanding, they should be same because somefunction can only return exactly one value.

    Continue reading...

Compartilhe esta Página