Steven Bethard wrote: > Fernando Perez wrote: >> classes which implement slicing must now do runtime type-checking inside >> __getitem__. > > Just in case you thought that they wouldn't have to do runtime > type-checking otherwise: > > >>> class C(object): > ... def __getitem__(self, x): > ... print type(x), x > ...
[...] > You can put just about anything in a __getitem__ call. Do you really > want a method for each of the variants above? I guess that conceptually it just felt natural to me to keep separate methods for dealing with a slice (get many elements out) and other types of indexing, which I tend to think of as 'scalar' indexing. Regards, f -- http://mail.python.org/mailman/listinfo/python-list