3 Sep
2021
3 Sep
'21
8:15 p.m.
On Sat, Sep 4, 2021 at 6:06 AM Kevin Mills <kevin.mills226@gmail.com> wrote:
If we don't cheat by comparing expressions to expression lists, the two are fairly analogous. `f(t)` means pass the tuple to the function, and `d[t]` means use the tuple as a key. `f(*t)` means break up the tuple and pass each element as an argument to the function, and `d[*t]` means break up the tuple and pass each element to getitem in turn.
Cheat? But that's the exact context in which starred expressions have meaning. When you call f(1,2,3), you're not calling f(1)(2)(3). You're passing all of those arguments to a single function call. That's why d[*t] would have to mean d[1,2,3] not d[1][2][3]. ChrisA