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 [tex2html_wrap1124]such that [tex2html_wrap1126]where [tex2html_wrap1128]and [tex2html_wrap1130]are the specified lower and upper bounds. This may be an empty sequence. It is not an error if [tex2html_wrap1132]or [tex2html_wrap1134]lie outside the range of valid indexes (such items don't exist so they aren't selected).


guido@cwi.nl