On 2019-12-12 19:01, Andrew Barnert via Python-ideas wrote:
On Dec 12, 2019, at 10:19, Ricky Teachey <ri...@teachey.org> wrote:


        As an aside, I've occasionally wished that [] would be the
        same as [()], by analogy to [1,2].


     In that universe, would (((((),),),),) be the same as ()?


  Sorry: I suppose what I meant was: ((((())))) would be the same as ().

It already is the same:

     >>> ((((()))))
     ()

So presumably it would still be the same in that universe. :)

I don’t see any problem with a[] being the same as a[()]. We already have a[1,] is the same as a[(1,)] rather than a[1], and this case wouldn’t even have that potential for confusion.

There are presumably historical reasons why it turned out this way, but if you were designing a new language that had tuple and slice and ellipsis indexing like current Python, would you expect [] to be anything other than [()], or find it confusing?

An alternative meaning could be [:], returning a copy, with the advantage that it could also be used with dicts. Which would be more useful: copying, or indexing with an empty tuple?
_______________________________________________
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/7D24OSCRW5CVYXPYVKLYC55IEV4K4RMW/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to