[PYTHON MATRIX-SIG] A problem with slicing
Jim Fulton, U.S. Geological Survey
Thu, 14 Sep 1995 11:13:03 -0400
On Thu, 14 Sep 1995 10:55:32 -0400
Guido van Rossum said:
> > 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
> while there is no equivalent
> I could either tweak the priorities so that
> is parsed as
> a[(1,2) : (3,4)]
Can't be, ":" wants integers.
> or so that it is parsed as
> a[1, (2:3), 4]
Can't be, (2:3) is not a valid expression, so it can't yield a valid
element of the tuple.
> 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.
But ":" only makes sense for sequences and "," only makes sense for
mappings, so ":" and "," should never appear together in s. I don't
think this is a precedence issue. I see your point that ":"
complicates things a bit. You not only have to recognize ",", but you
have to make sure that it is not used in conjunction with ":".
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: email@example.com
administrivia to: firstname.lastname@example.org