RE: empty subscripts:
Should something be allowed syntax?
In a way this comes down to design philosophy vs implementation.
From an implementation perspective, the  operator is another way to call __getitem__ and __setitem__. And from that perspective, why not have it act like a function call: no arguments, positional arguments, keyword arguments, the whole shebang.
But from a language design perspective, the  operator is a way to "index" a container -- get part of the container's contents. And from this perspective, no index makes no sense.
I like to think of the dunders as an implementation detail, so no, the square brackets have a distinct meaning that is different from the parentheses, and should not have the same features.
another way to think of it is that we shouldn't encourage folks to "abuse" the  as simply an alternative way to call the object.
On Mon, Aug 17, 2020 at 4:06 AM Antoine Pitrou firstname.lastname@example.org wrote:
On Mon, 17 Aug 2020 22:54:32 +1200
Greg Ewing email@example.com wrote:
On 17/08/20 9:58 pm, Antoine Pitrou wrote:
Probably because exploiting Python abstraction facilities to build DSLs
has/had long been frown upon in this community? That was the leitmotiv
back when people were marvelling over Ruby's flexibility in the area.
As far as I remember, what was frowned on was adding weird and
wonderful syntax (e.g. function calls without parens) to Python
purely because "it might be useful for DSLs".
Notice that such weird and wonderful syntax was proposed again by Guido
And as I said, annotations have become a DSL in themselves, and several
PEPs are dedicated to that DSL.
wrong with using existing features to build DSLs (although
people might look askance at you if you use them in particularly
Well, we're not talking about an existing feature in this thread.
Python-ideas mailing list -- firstname.lastname@example.org
To unsubscribe send an email to email@example.com
Message archived at https://firstname.lastname@example.org/message/SZQUVE...
Code of Conduct: http://python.org/psf/codeofconduct/