FEEDBACK WANTED: Type/class unification
jeff at ccvcorp.com
Tue Aug 7 21:01:09 CEST 2001
Markus Schaber wrote:
> Dylan Thurston <dpt at abel.math.harvard.edu> schrub:
> > Let me complain a little about the slicing interface while I'm at it.
> > I don't understand why missing endpoints are turned into 0/maxint
> > (rather than, say, 'None') before calling __getitem__; it removes a
> > lot of flexibility. Also, why are the slices restricted to being
> > integers? I can imagine, say, slicing a 2-dimensional array based on
> > the endpoints (like 'delete-rectangle', etc. in Emacs).
> With the automatic turning to 0/maxint, they even are limited to
> non-negative integers. So it is impossible to use any form of negative
> indexes, which sometimes would be nice when dealing with coordinates.
Um.... you *can* use negative values in slices:
>>> mylist = [1, 2, 3, 4]
>>> mylist [:-2]
What you can't have, is negative indices into a list. Neither of these,
however, have anything to do with the specific case being discussed, which
is the default value used for unspecified slice endpoints.
A list of lists is really not the same thing as a 2d-array, and is probably
not suitable for use as a coordinate system. If you really *must* do so,
though, and your coordinates *must* include negative values, then you could
wrap the list of lists into a class and provide an automatic translation.
More information about the Python-list