slicing, mapping types, ellipsis etc.

Nick Coghlan ncoghlan at
Tue Nov 30 14:52:16 CET 2004

Kent Johnson wrote:
> 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."

In the section you mention, 'mapping' is equivalent to 'has __getitem__ 
defined', and I'd be surprised if it's an isolated usage. Python actually has 
trouble distinguishing between sequences and mappings, as anyone who as tried to 
use the 'isMapping' API would know (the isMapping API uses much the same 
definition as the reference manual does - so all sequences show up as mappings, 
as they map indices and slices to objects).

Section 3 of the reference manual is actually more use for anyone developing 
custom types that override special methods. E.g. proper handling of slice 
objects is described here under container emulation:


More information about the Python-list mailing list