[PYTHON MATRIX-SIG] A problem with slicing

Jim Fulton, U.S. Geological Survey jfulton@usgs.gov
Thu, 14 Sep 1995 10:50:25 -0400

On Thu, 14 Sep 1995 10:39:00 -0400 
Guido van Rossum said:
> > I really don't see any reason why the matrix type should require
> > language changes (aside from the minor impact of the tuplefication
> > operator).
> I guess one of my points was that, given the desire for a fairly
> consistent design, allowing tuples as indices is *not* a minor
> change...

I'm not suggesting that tuples should be allowed as indexes to
sequence types.  Tuples are *already* allowed as indexes to mapping
types.  I propose that matrices should provide *both* sequence and
mapping behavior, where the mapping behavior is used to support matrix
slicing. This requires *no* change to the language.

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:


is equivalent to:



  for spam in 1,2,3:

is equivalent to:

  for spam in (1,2,3):

so why isn't:


equivalent to:


Note that this change is cosmetic (like making modules callable ;-),
and is not *needed* for the matrix proposal.


MATRIX-SIG  - SIG on Matrix Math for Python

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