On Mon, Oct 7, 2019, at 18:19, Cameron Simpson wrote:
> On 07Oct2019 10:56, Joao S. O. Bueno <jsbu...@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')
_______________________________________________
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/YMW2WDLNATTNAG22ZDD4HBQLDW3LDABT/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to