
On Mon, Oct 7, 2019, at 18:19, Cameron Simpson wrote:
On 07Oct2019 10:56, Joao S. O. Bueno <jsbueno@python.org.br> wrote:
So, in short, your idea is to allow "=" signs inside `[]` get notation to be translated to dicts on the call,
Subjectively that seems like a tiny tiny win. I'm quite -1 on this idea; language spec bloat to neglible gain.
in the same way comma separated values are translated to tuples?
Chris pointed out to me recently that tuples don't need commas, the commas alone suffice. You see brackets _around_ tuples a lot because of precedence.
To be clear, since slices can be a member of the tuple, the subscripting syntax does have to handle commas specially - it doesn't simply fall out of the regular tuple syntax as you may be suggesting. You also, can't, for example, use "*sequence" inside the subscripting brackets, whereas you can for normal tuples even without parentheses.
class C: ... def __getitem__(self, i): return i ... C()[1:2, 3:4] (slice(1, 2, None), slice(3, 4, None)) C()[1, 2, *'ab'] File "<stdin>", line 1 C()[1, 2, *'ab'] ^ SyntaxError: invalid syntax x = 1, 2, *'ab' x (1, 2, 'a', 'b')