On Sat, 29 Aug 2020 at 18:04, Jonathan Fine <jfine2...@gmail.com> wrote: > > Paul Moore wrote: > >> But you don't give any reason why you'd want to do that. Why are you >> using subscript notation rather than a simple function call? > > > Good point. Consider > >>> def f(*argv): pass > >>> d = dict() > > Now compare > >>> f(1, 2) = 3 > SyntaxError: can't assign to function call > >>> d[1, 2] = 3 > >>> d[1, 2] > 3
Obviously. As it says, you can't assign to a function call. > Item assignment (ie __setitem__) is the one thing that a function call can't > do. If we want keywords in our __getitem__ and so on commands, then one route > for item assignment is to allow > >>> d[1, 2, a=3, b=4] = 5 > as valid syntax. Again, obvious. But you still haven't given any reason why we would want to do that. No-one's arguing that these things aren't possible, or that the proposals can't be implemented. What I'm asking, and you aren't answering, is what is the use case? When, in real world code, would this be used? Also, by being this abstract, you've ended up arguing without any context. If I say "yes, d[1, 2, a=3, b=4] = 5" might be useful, you've not got anywhere, because all of the proposals being discussed are about allowing this, so even if you *do* get agreement on this point, you're barely moving the discussion forward at all. > By the way, another route is to use a simple function call, like so > >>> d[o(1, 2, a=3, b=4)] = 5 > which is already possible today. Some of us don't like this route. Exactly. Pick a proposed solution and find use cases and arguments for it. Don't argue for ideas that are so abstract that they gloss over all the details that differentiate between the various implementation options. Paul _______________________________________________ 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/AHVPKDFI4DSPJQ6PVXAXADIFGBTQMS7W/ Code of Conduct: http://python.org/psf/codeofconduct/