slicing, mapping types, ellipsis etc.

Kent Johnson kent3737 at yahoo.com
Tue Nov 30 07:55:21 EST 2004


Nick Coghlan wrote:
> Jerry Sievers wrote:
> 
>> Fellow Pythonists;
>>
>> I am totally puzzled on the use of slicing on mapping types and
> 
> 
> It's generally not supported (since slices are designed to work with the 
> numerical indices of a sequence, not the arbitrary keys of a mapping).

Section 5.3.3 of the Language Reference seems to say that with extended 
slicing, the slice elements are used to create a key that indexes a 
mapping. "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."

 From my understanding of this thread so far, extended slicing is used 
as a form of indexing in Numeric. Are Numeric arrays considered 
mappings? Or is this paragraph in 5.3.3 off the mark?

Maybe instead of referring to mappings it should say "The primary must 
implement __getitem__(), which is called with a value that is 
constructed from the slice list, as follows."

Kent



More information about the Python-list mailing list