31 Aug
2020
31 Aug
'20
6:56 a.m.
On 31/08/20 4:11 pm, Guido van Rossum wrote:
Can I write a.__getitem__((1, 2), k=3) and the function will see (i, j, k) == (1, 2, 3)?
Yes.
Okay, and if I write a.__getitem__((1, 3), k=2) will the function see the same thing?
No, it will see (i, j, k) == (1, 3, 2). It's the same as if you were calling an ordinary function and passing the tuple using *:
def f(i, j, k): ... print(i, j, k) ... f(*(1, 2), k = 3) 1 2 3 f(*(1, 3), k = 2) 1 3 2
I've got the feeling you're pranking me here, and I'm falling for it hook, line and sinker.
No, it was a serious suggestion. But if you don't like it, that's fine. -- Greg