[PYTHON MATRIX-SIG] Slices

Konrad HINSEN hinsenk@ere.umontreal.ca
Wed, 3 Apr 1996 12:30:25 -0500


> There are problems with this as I found when initially considering
> such a possibility.  If ":" notation is allowed wherever a "test"
> expression can occur then there can be ambiguity with statements where
> ":" is used to introduce a compound statement, i.e. in "for" or "if"
> statements. 

I see. That's of course a good argument.

> I think that we will have to go with option (2).  However, the
> interface to Slice() should change to duplicate ":" rather than have
> the old interface.

But that is rather difficult with standard function-call syntax.

Another idea: introduce an object "index_expression" that can be
indexed to get an equivalent expression. Then
   i = index_expression[2:4,...]
   a[i]
would be equivalent to
   a[2:4,...]
There would be no new syntax to learn; although users might have
to know that index expressions are really tuples if they want
to do something that is not possible with standard indexing.

-------------------------------------------------------------------------------
Konrad Hinsen                     | E-Mail: hinsenk@ere.umontreal.ca
Departement de chimie             | Tel.: +1-514-343-6111 ext. 3953
Universite de Montreal            | Fax:  +1-514-343-7586
C.P. 6128, succ. Centre-Ville     | Deutsch/Esperanto/English/Nederlands/
Montreal (QC) H3C 3J7             | Francais (phase experimentale)
-------------------------------------------------------------------------------

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

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