On Mon, Aug 31, 2020, 3:10 AM Greg Ewing <greg.ew...@canterbury.ac.nz> wrote:
> I'm wondering whether parens should be required when there are both > keyword args and more than one positional arg in an index. I.e instead > of > > a[1, 2, k = 3] > > you would have to write > > a[(1, 2), k = 3] > > That would make it clearer that the indexing syntax still really only > takes one positional arg, and why, if you transform it into > > idx = (1, 2) > a[idx, k = 3] > > you don't/can't write it as > > a[*idx, k = 3] > > -- > Greg Yes. Please. We've already created a screwy situation now that people seem to agree kwd args is something we want here. I really don't want to see it get even more screwy by allowing syntax that looks so very much like a standard function call, except with a different bracket shape, and acts totally differently underneath. If we are not going to fix things to utilize functional style arguments using a new dunder or dunders, and we're not willing to break anything now or in the future, this limitation seems very wise to me. And the limitation will also leave open the door to more easily allowing a functional style option. Right now we have this problem to deal with: f(1) f(1,) q[1] q[1,] ...the f's and the q's can't be reconciled because History. We are creating a second problem except worse: f(1, 2, k=3) f((1, 2), k=3) q[1, 2, k=3] q[(1, 2), k=3] ...these won't be able to be reconciled with each other if we go forward with allowing tuples to *poof* into existence regardless of whether there is a bunch of keywords hanging off the end in the subscript brackets. Would we ever in a million years have syntax like this? What could this mean? a = [x, y, k=3] I'd say no, syntax like this is just weird. But if it did, would you expect x,y to get packed into a tuple together...? Nobody would.
_______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/JZA4PRKTTATDSYKIXXYDQZ2VCGDG2WXX/ Code of Conduct: http://python.org/psf/codeofconduct/