Slice inconsistency?

Terry Reedy tjreedy at
Sat Sep 27 19:15:34 CEST 2003

"Roberto A. F. De Almeida" <roberto at> wrote in message
news:10c662fe.0309270545.1fd5d839 at
> Stephen Horne <$$$$$$$$$$$$$$$$$@$$$$$$$$$$$$$$$$$$$$> wrote
in message news:<bqeanvgel9ra3va44j090bmn2l126t340g at>...
> > That is, whether the single or multiple notation is used, and
> > the slice objects are placed in a tuple or not, they are
> > from the tuple notation - the translation from notation to slice
> > object should be done consistently.
> Yes, I believe I was not very clear. This is the inconsistency I was
> talking about. (And this is with Python 2.3.1)

As I pointed out in response to the same message, there is no
inconsistency because the premise behind that conclusion is wrong.  I
also pointed out that you can make the premise true and get the
consistency you expect by adding a comma after single slice
expressions so that you do always use tuple notation.

[me]> > >What you probably want is b[:-1][:-1], etc.  Each index must
> > >separately bracketed to access items in list of lists (etc).

> The problem with b[:-1][:-1] is that it will return b[:-1], and then
> slice the result again. It's ok if you're working with lists, but
> for what I'm doing.
> and request from the server only the data that will be used, and
> return it as a Numeric array.

Then you should, of course, use N.P.'s extended slicing syntax and I
would expect all to work well.  If you are doing something just
similar, then you will have to do similar custom interpretation of
slice tuples.

Terry J. Reedy

More information about the Python-list mailing list