[PYTHON MATRIX-SIG] A problem with slicing

Guido van Rossum guido@CNRI.Reston.VA.US
Thu, 14 Sep 1995 10:55:32 -0400


> The only *minor* change proposed, which I could live without is to
> allow the "," to generate tuples inside of []s, just as it does
> outside of [].  In fact, I view the current non-recognition of tuples
> in []s as an inconsistency.  For example:
[...]
> so why isn't:
> 
>   a[1,2,3]
> 
> equivalent to:
> 
>   a[(1,2,3)]

Because there's also

    a[1:2]

while there is no equivalent

    a(1:2)

I could either tweak the priorities so that

    a[1,2:3,4]

is parsed as

    a[(1,2) : (3,4)]

or so that it is parsed as

    a[1, (2:3), 4]

but neither appears very natural to me.

I guess my problem is that ":" and "," have "fuzzy" priorities, and
while everybody agrees that e.g. "*" binds tighter than "+", if you
ask a few people in the street, or even computer programmers, you'd
get confused answers.

--Guido van Rossum <guido@CNRI.Reston.VA.US>
URL: <http://www.python.org/~guido/>

=================
MATRIX-SIG  - SIG on Matrix Math for Python

send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
=================