Slicing beyond list -- bug or featurette?
Konrad Hinsen
hinsen at cnrs-orleans.fr
Wed Jul 7 04:16:09 EDT 1999
Pierre Fortin <pfortin at cisco.com> writes:
> list[2:50] returns [ 2,3,4 ]
> list[20:] or list[20:30] returns []
>
> Can I count on this, or should I code try/except for the day it's
> fixed? This 'feature' reduces the error situations; but is it
> correct/intended?
Here's what the language reference manual says:
Sequences also support slicing: a[i:j]selects all items with index k
such that i <=k < j.
There is no mention of an error condition, and the description agrees
with the behaviour of the interpreter, so I'd consider it a feature.
--
-------------------------------------------------------------------------------
Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr
Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69
Rue Charles Sadron | Fax: +33-2.38.63.15.17
45071 Orleans Cedex 2 | Deutsch/Esperanto/English/
France | Nederlands/Francais
-------------------------------------------------------------------------------
More information about the Python-list
mailing list