[Python] Why/when/where was `mydict[*mylist]` introduced? [duplicate]

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

  1. Stack

    Stack Membro Participativo

    This shorthand to use lists as dict keys works in Python 3.12:

    mydict = {(1, 2, 3): 'works!'}
    mylist = [1, 2, 3]
    print(mydict[*mylist])


    In 3.10 it gives SyntaxError and in 3.11 it works (at least in the versions I tried). I searched What’s New In Python 3.11 but didn't see anything about it. Maybe it was a side effect of some other change. Why/where/when was it introduced? Looking for (information from) a GitHub issue / pull request or so.

    Continue reading...

Compartilhe esta Página