Tim Hochberg wrote: > [EMAIL PROTECTED] wrote: > > Fredrik Lundh wrote: > > > >>>Python now has, what, three built-in mutable collections types: > >>>lists, dictionaries, and sets. Dicts and sets both have a clear() > >>>method and lists do not. > >> > >>dicts and sets are mappings, and lists are not. mappings don't > >>support slicing. lists do. > > > > > > I am confused. Could you explain this ? I was under the impression said > > above(mapping don't support slicing), until after I read the language > > reference. I don't think it is slicing as in the list slicing sense but > > it does use the term "extend slicing". > > > > http://www.python.org/doc/2.4.2/ref/slicings.html > > > > "The semantics for an extended slicing are as follows. The primary must > > evaluate to a mapping object, and it is indexed with a key that is > > constructed from the slice list, as follows. If the slice list contains > > at least one comma, the key is a tuple containing the conversion of the > > slice items; otherwise, the conversion of the lone slice item is the > > key. The conversion of a slice item that is an expression is that > > expression. The conversion of an ellipsis slice item is the built-in > > Ellipsis object. The conversion of a proper slice is a slice object > > (see section 3.2) whose start, stop and step attributes are the values > > of the expressions given as lower bound, upper bound and stride, > > respectively, substituting None for missing expressions." > > > This is in place to support multidimensional arrays, such as in numpy. > If, for instance, you have a 9x9 array A, then A[3:6,3:6] will extract a > 3x3 block from the center of it. A[3:6,3:6] is equivalent to > A[(slice(3,6,None), slice(3,6,None))] and the resulting tuple gets > passed through the mapping interface, but it is not a mapping in any > real sense. > > I don't think there's anything in core Python that uses this and it's > not really relevant to this thread. > Thanks. I would say that it is not relevant to the OP's question but the thread has turned to "anyone who read the doc should know about slicing" and that prompted me to go and read the doc(I don't have the OP's mentioned need in my coding so far and never read about the full pontential of slicing, just use it as the right hand side intuitively) about slicing and found the documentation to be a bit lacking(only a brief mentioning of slicing in the turtorial and this confusing section).
Beside, just from reading this page, it seems that a[start:stop:stride] is not a valid construction for sequence object 'a'. To me, reading the doc makes me more confuse about what is slicing. -- http://mail.python.org/mailman/listinfo/python-list