next up previous contents index
Next: Calls Up: Primaries Previous: Subscriptions

Slicings

   

A slicing (or slice) selects a range of items in a sequence (string, tuple or list) object:            

slicing:        primary "[" [condition] ":" [condition] "]"

The primary must evaluate to a sequence object. The lower and upper bound expressions, if present, must evaluate to plain integers; defaults are zero and the sequence's length, respectively. If either bound is negative, the sequence's length is added to it. The slicing now selects all items with index k such that i <= k < j where i and j are the specified lower and upper bounds. This may be an empty sequence. It is not an error if i or j lie outside the range of valid indexes (such items don't exist so they aren't selected).



guido@cwi.nl